Skip to content

Commit

Permalink
Merge pull request #76 from qld-gov-au/develop
Browse files Browse the repository at this point in the history
Develop to master - restrict lock timeout to prevent deadlocks
  • Loading branch information
ThrawnCA authored Jan 15, 2024
2 parents 8ed9ce9 + 6cae283 commit 3a47541
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ckanext/xloader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,9 @@ def _clear_datastore_resource(resource_id):
''' Delete all records from the datastore table, without dropping the table itself.
'''
engine = get_write_engine()
connection = engine.connect()
try:
connection.execute('TRUNCATE TABLE "{}"'.format(resource_id))
finally:
connection.close()
with engine.begin() as conn:
conn.execute("SET LOCAL lock_timeout = '5s'")
conn.execute('TRUNCATE TABLE "{}"'.format(resource_id))


def load_csv(csv_filepath, resource_id, mimetype='text/csv', logger=None):
Expand Down

0 comments on commit 3a47541

Please sign in to comment.