diff 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
line wrap: on
line diff
--- a/MySQL/Plugins/MySQLStorageArea.cpp	Wed May 08 20:21:13 2019 +0200
+++ b/MySQL/Plugins/MySQLStorageArea.cpp	Wed May 08 21:09:18 2019 +0200
@@ -42,6 +42,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
+     **/
+    MySQLDatabase::TransientAdvisoryLock lock(*db, 44 /* some arbitrary constant */);
+    
     {
       MySQLTransaction t(*db);