diff 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
line wrap: on
line diff
--- a/MySQL/Plugins/MySQLIndex.cpp	Wed May 08 20:21:13 2019 +0200
+++ b/MySQL/Plugins/MySQLIndex.cpp	Wed May 08 21:09:18 2019 +0200
@@ -76,6 +76,14 @@
     {
       db->AdvisoryLock(42 /* 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);