Mercurial > hg > orthanc-databases
comparison 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 |
comparison
equal
deleted
inserted
replaced
133:b1d7d255fb73 | 134:cc3dc759c989 |
---|---|
38 if (parameters_.HasLock()) | 38 if (parameters_.HasLock()) |
39 { | 39 { |
40 db->AdvisoryLock(43 /* some arbitrary constant */); | 40 db->AdvisoryLock(43 /* some arbitrary constant */); |
41 } | 41 } |
42 | 42 |
43 /** | |
44 * Try and acquire a transient advisory lock to protect the setup | |
45 * of the database, because concurrent statements like "CREATE | |
46 * TABLE" are not protected by transactions. | |
47 * https://groups.google.com/d/msg/orthanc-users/yV3LSTh_TjI/h3PRApJFBAAJ | |
48 **/ | |
49 PostgreSQLDatabase::TransientAdvisoryLock lock(*db, 44 /* some arbitrary constant */); | |
50 | |
43 if (clearAll_) | 51 if (clearAll_) |
44 { | 52 { |
45 db->ClearAll(); | 53 db->ClearAll(); |
46 } | 54 } |
47 | 55 |