AttributeError: 'NoneType' object has no attribute 'paused'

We just upgraded from v8.0 to v10.1.0 yesterday and on some queries(which were working fine previously) we are getting the below error.

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1949, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File “/usr/local/lib/python3.7/site-packages/flask_restful/init.py”, line 458, in wrapper
resp = resource(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/flask_login/utils.py”, line 261, in decorated_view
return func(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/flask/views.py”, line 89, in view
return self.dispatch_request(*args, **kwargs)
File “/app/redash/handlers/base.py”, line 33, in dispatch_request
return super(BaseResource, self).dispatch_request(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/flask_restful/init.py”, line 573, in dispatch_request
resp = meth(*args, **kwargs)
File “/app/redash/permissions.py”, line 71, in decorated
return fn(*args, **kwargs)
File “/app/redash/handlers/query_results.py”, line 311, in post
max_age,
File “/app/redash/handlers/query_results.py”, line 66, in run_query
if data_source.paused:
AttributeError: ‘NoneType’ object has no attribute ‘paused’

Could not find any similar errors with other people. I followed the v10.0 upgrade guide and only substituted the image version for the 10.1 upgrade.

What can we do to resolve this?