Prevent sqlalchemy from refetching the old_state_id as it will never change (#40982)

Disable expire_on_commit for the event writer. Since we never expect the
old_state_id to change in the database, it was never worth the expense of
refetching the id after the commit.
This commit is contained in:
J. Nick Koston 2020-10-01 12:57:52 -05:00 committed by GitHub
parent cf785b86db
commit 6b509fd9db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -573,7 +573,9 @@ class Recorder(threading.Thread):
sqlalchemy_event.listen(self.engine, "connect", setup_recorder_connection) sqlalchemy_event.listen(self.engine, "connect", setup_recorder_connection)
Base.metadata.create_all(self.engine) Base.metadata.create_all(self.engine)
self.get_session = scoped_session(sessionmaker(bind=self.engine)) self.get_session = scoped_session(
sessionmaker(bind=self.engine, expire_on_commit=False)
)
def _close_connection(self): def _close_connection(self):
"""Close the connection.""" """Close the connection."""