Disable session synchronization on deletes

This commit switches the synchronization_session option on the delete()
calls in the delete_old*() methods in the db api. When setting session
synchronization sqlalchemy is trying to keep a local cache of the data
being deleted. For large DBs like, the infra one, this can eat too
much RAM, which depending on the system might invoke the OOM killer.

Change-Id: Iff5112072fd64d6b96666654edd7cb17897d0765
This commit is contained in:
Matthew Treinish 2016-01-12 15:22:50 -05:00
parent 3bd7f9ff3f
commit a506cfe1dd
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177

View File

@ -960,10 +960,10 @@ def delete_old_runs(expire_age=186, session=None):
models.Run.run_at < expire_date).subquery()
db_utils.model_query(models.RunMetadata, session).filter(
models.RunMetadata.run_id.in_(sub_query)).delete(
synchronize_session='fetch')
synchronize_session=False)
# Delete the runs
db_utils.model_query(models.Run, session).filter(
models.Run.run_at < expire_date).delete(synchronize_session='evaluate')
models.Run.run_at < expire_date).delete(synchronize_session=False)
def delete_old_test_runs(expire_age=186, session=None):
@ -981,11 +981,11 @@ def delete_old_test_runs(expire_age=186, session=None):
models.TestRun.start_time < expire_date).subquery()
db_utils.model_query(models.TestRunMetadata, session).filter(
models.TestRunMetadata.test_run_id.in_(sub_query)).delete(
synchronize_session='fetch')
synchronize_session=False)
# Delete the test runs
db_utils.model_query(models.TestRun, session).filter(
models.TestRun.start_time < expire_date).delete(
synchronize_session='evaluate')
synchronize_session=False)
def get_id_from_test_id(test_id, session=None):