Redash giving internal server error many times when anyone execute query, the logs are giving following error when redash shows error:

[ERROR][ForkPoolWorker-11] Task redash.tasks.execute_query[e45a3821-741b-4ca3-ad53-71332e598402] raised unexpected: OperationalError(’(psycopg2.OperationalError) SSL SYSCALL error: EOF detected\n’,)
Traceback (most recent call last):
File “/usr/local/lib/python2.7/site-packages/celery/app/trace.py”, line 385, in trace_task
R = retval = fun(*args, **kwargs)
File “/app/redash/worker.py”, line 84, in call
return TaskBase.call(self, *args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/celery/app/trace.py”, line 648, in protected_call
return self.run(*args, **kwargs)
File “/app/redash/tasks/queries.py”, line 436, in execute_query
scheduled_query).run()
File “/app/redash/tasks/queries.py”, line 391, in run
run_time, utcnow())
File “/app/redash/models/init.py”, line 314, in store_result
for q in queries:
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py”, line 2994, in iter
self.session._autoflush()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py”, line 1444, in _autoflush
util.raise_from_cause(e)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py”, line 265, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py”, line 1434, in _autoflush
self.flush()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py”, line 2254, in flush
self._flush(objects)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py”, line 2380, in _flush
transaction.rollback(_capture_exception=True)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py”, line 66, in exit
compat.reraise(exc_type, exc_value, exc_tb)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py”, line 2344, in _flush
flush_context.execute()
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py”, line 391, in execute
rec.execute(self)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py”, line 556, in execute
uow
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py”, line 181, in save_obj
mapper, table, insert)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py”, line 866, in _emit_insert_statements
execute(statement, params)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 948, in execute
return meth(self, multiparams, params)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py”, line 269, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 1060, in _execute_clauseelement
compiled_sql, distilled_params
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 1200, in _execute_context
context)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 1413, in _handle_dbapi_exception
exc_info
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py”, line 265, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py”, line 1193, in _execute_context
context)
File “/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py”, line 509, in do_execute
cursor.execute(statement, parameters)
OperationalError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (psycopg2.OperationalError) SSL SYSCALL error: EOF detected
[SQL: ‘INSERT INTO query_results (org_id, data_source_id, query_hash, query, data, runtime, retrieved_at) VALUES (%(org_id)s, %(data_source_id)s, %(query_hash)s, %(query)s, %(data)s, %(runtime)s, %(retrieved_at)s) RETURNING query_results.id’] [parameters: