Mercurial > hg > orthanc-databases
diff PostgreSQL/Plugins/PostgreSQLStorageArea.cpp @ 134:cc3dc759c989
Added an advisory lock to avoid race conditions during database setup
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 08 May 2019 20:21:13 +0200 |
parents | 714c5d2bee76 |
children | 3266785d5627 |
line wrap: on
line diff
--- a/PostgreSQL/Plugins/PostgreSQLStorageArea.cpp Fri Mar 01 12:56:13 2019 +0100 +++ b/PostgreSQL/Plugins/PostgreSQLStorageArea.cpp Wed May 08 20:21:13 2019 +0200 @@ -40,6 +40,14 @@ db->AdvisoryLock(43 /* some arbitrary constant */); } + /** + * Try and acquire a transient advisory lock to protect the setup + * of the database, because concurrent statements like "CREATE + * TABLE" are not protected by transactions. + * https://groups.google.com/d/msg/orthanc-users/yV3LSTh_TjI/h3PRApJFBAAJ + **/ + PostgreSQLDatabase::TransientAdvisoryLock lock(*db, 44 /* some arbitrary constant */); + if (clearAll_) { db->ClearAll();