title: server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request
body: <p>I am using sqlalchemy(<code>sqlalchemy==1.4.6</code>) to do a query, the database is PostgreSQL 13, this is my Python 3 code look like:</p>
  <pre><code>def select_channel_by_id(self, channel_id):
      with session_scope() as local_session:
          rss = None
          try:
              rss = local_session.query(RssSource).filter(RssSource.id == channel_id).one()
          except SQLAlchemyError as e:
              local_session.rollback()
              logger.error(&quot;query rss source by id error&quot;, e)
          finally:
              local_session.close()
          return rss
  </code></pre>
  <p>when I run to this code, shows error like this:</p>
  <pre><code>[2021-10-25 18:42:00,040: WARNING/ForkPoolWorker-3]   File &quot;/usr/local/lib/python3.9/site-packages/celery/app/trace.py&quot;, line 731, in __protected_call__
      return self.run(*args, **kwargs)
  
  [2021-10-25 18:42:00,040: WARNING/ForkPoolWorker-3]   File &quot;/root/pydolphin/dolphin/tasks/tasks.py&quot;, line 33, in pull_channel_impl
      source = rss.select_channel_by_id(channel_id)
  
  [2021-10-25 18:42:00,040: WARNING/ForkPoolWorker-3]   File &quot;/root/pydolphin/dolphin/common/db/rss_source.py&quot;, line 61, in select_channel_by_id
      logger.error(&quot;query rss source by id error&quot;, e)
  
  [2021-10-25 18:42:00,040: WARNING/ForkPoolWorker-3] Message: 'query rss source by id error'
  Arguments: (OperationalError('(psycopg2.OperationalError) server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\n'),)
  </code></pre>
  <p>why would this happen? what should I do to fix this problem? BTW, this is my session scope look like:</p>
  <pre><code>@contextmanager
  def session_scope():
      scope_session = Session()
      try:
          yield scope_session
          scope_session.commit()
      except Exception as e:
          scope_session.rollback()
          logger.error(&quot;session management error&quot;, e)
      finally:
          scope_session.close()
  </code></pre>
  <p>this is my PostgreSQL(deploy in kubernetes cluster) log look like:</p>
  <pre><code>2021-10-25 11:03:34.794 GMT [29779] LOG:  could not receive data from client: Connection reset by peer
  2021-10-25 11:04:07.562 GMT [29800] LOG:  could not receive data from client: Connection reset by peer
  2021-10-25 11:04:07.563 GMT [29801] LOG:  could not receive data from client: Connection reset by peer
  2021-10-25 11:04:07.565 GMT [29799] LOG:  could not receive data from client: Connection reset by peer
  2021-10-25 11:04:07.566 GMT [29796] LOG:  could not receive data from client: Connection reset by peer
  2021-10-25 11:04:07.568 GMT [29795] LOG:  could not receive data from client: Connection reset by peer
  2021-10-25 11:04:07.569 GMT [29798] LOG:  could not receive data from client: Connection reset by peer
  2021-10-25 11:04:07.571 GMT [29794] LOG:  could not receive data from client: Connection reset by peer
  2021-10-25 11:04:07.572 GMT [29797] LOG:  could not receive data from client: Connection reset by peer
  </code></pre>