Mercurial > hg > orthanc-databases
comparison MySQL/Plugins/MySQLStorageArea.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 | 714c5d2bee76 |
children | 52b3859ee0b7 |
comparison
equal
deleted
inserted
replaced
134:cc3dc759c989 | 135:e26690365c25 |
---|---|
40 if (parameters_.HasLock()) | 40 if (parameters_.HasLock()) |
41 { | 41 { |
42 db->AdvisoryLock(43 /* some arbitrary constant */); | 42 db->AdvisoryLock(43 /* some arbitrary constant */); |
43 } | 43 } |
44 | 44 |
45 /** | |
46 * Try and acquire a transient advisory lock to protect the setup | |
47 * of the database, because concurrent statements like "CREATE | |
48 * TABLE" are not protected by transactions. | |
49 * https://groups.google.com/d/msg/orthanc-users/yV3LSTh_TjI/h3PRApJFBAAJ | |
50 **/ | |
51 MySQLDatabase::TransientAdvisoryLock lock(*db, 44 /* some arbitrary constant */); | |
52 | |
45 { | 53 { |
46 MySQLTransaction t(*db); | 54 MySQLTransaction t(*db); |
47 | 55 |
48 int64_t size; | 56 int64_t size; |
49 if (db->LookupGlobalIntegerVariable(size, "max_allowed_packet")) | 57 if (db->LookupGlobalIntegerVariable(size, "max_allowed_packet")) |