comparison PostgreSQL/Plugins/PostgreSQLIndex.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 e61587582cef
children 3266785d5627
comparison
equal deleted inserted replaced
133:b1d7d255fb73 134:cc3dc759c989
72 if (parameters_.HasLock()) 72 if (parameters_.HasLock())
73 { 73 {
74 db->AdvisoryLock(42 /* some arbitrary constant */); 74 db->AdvisoryLock(42 /* some arbitrary constant */);
75 } 75 }
76 76
77 /**
78 * Try and acquire a transient advisory lock to protect the setup
79 * of the database, because concurrent statements like "CREATE
80 * TABLE" are not protected by transactions.
81 * https://groups.google.com/d/msg/orthanc-users/yV3LSTh_TjI/h3PRApJFBAAJ
82 **/
83 PostgreSQLDatabase::TransientAdvisoryLock lock(*db, 44 /* some arbitrary constant */);
84
77 if (clearAll_) 85 if (clearAll_)
78 { 86 {
79 db->ClearAll(); 87 db->ClearAll();
80 } 88 }
81 89