Mercurial > hg > orthanc-databases
comparison MySQL/Plugins/MySQLIndex.cpp @ 135:e26690365c25
MySQL: Added an advisory lock to avoid race conditions during database setup
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 08 May 2019 21:09:18 +0200 |
parents | 441a472bfd93 |
children | 52b3859ee0b7 |
comparison
equal
deleted
inserted
replaced
134:cc3dc759c989 | 135:e26690365c25 |
---|---|
74 | 74 |
75 if (parameters_.HasLock()) | 75 if (parameters_.HasLock()) |
76 { | 76 { |
77 db->AdvisoryLock(42 /* some arbitrary constant */); | 77 db->AdvisoryLock(42 /* some arbitrary constant */); |
78 } | 78 } |
79 | |
80 /** | |
81 * Try and acquire a transient advisory lock to protect the setup | |
82 * of the database, because concurrent statements like "CREATE | |
83 * TABLE" are not protected by transactions. | |
84 * https://groups.google.com/d/msg/orthanc-users/yV3LSTh_TjI/h3PRApJFBAAJ | |
85 **/ | |
86 MySQLDatabase::TransientAdvisoryLock lock(*db, 44 /* some arbitrary constant */); | |
79 | 87 |
80 { | 88 { |
81 MySQLTransaction t(*db); | 89 MySQLTransaction t(*db); |
82 | 90 |
83 db->Execute("ALTER DATABASE " + parameters_.GetDatabase() + | 91 db->Execute("ALTER DATABASE " + parameters_.GetDatabase() + |