Mercurial > hg > orthanc-databases
changeset 289:0868500060f3
Fix serialization of large jobs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Jun 2021 08:19:52 +0200 |
parents | 6d4d413a8797 |
children | 2790bafe3b3d |
files | Framework/Plugins/IndexUnitTests.h MySQL/NEWS MySQL/Plugins/MySQLIndex.cpp |
diffstat | 3 files changed, 46 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Plugins/IndexUnitTests.h Mon Jun 28 15:34:49 2021 +0200 +++ b/Framework/Plugins/IndexUnitTests.h Wed Jun 30 08:19:52 2021 +0200 @@ -523,7 +523,8 @@ ASSERT_EQ(p1, r); { - // Test creating a large property of 16MB + // Test creating a large property of 16MB (large properties are + // notably necessary to serialize jobs) // https://groups.google.com/g/orthanc-users/c/1Y3nTBdr0uE/m/K7PA5pboAgAJ std::string longProperty; longProperty.resize(16 * 1024 * 1024); @@ -534,9 +535,17 @@ db.SetGlobalProperty(*manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal8, longProperty.c_str()); + // The following line fails on MySQL 4.0 because the "value" + // column in "ServerProperties" is "TEXT" instead of "LONGTEXT" + db.SetGlobalProperty(*manager, "some-server", Orthanc::GlobalProperty_DatabaseInternal8, longProperty.c_str()); + std::string tmp; ASSERT_TRUE(db.LookupGlobalProperty(tmp, *manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseInternal8)); ASSERT_EQ(longProperty, tmp); + + tmp.clear(); + ASSERT_TRUE(db.LookupGlobalProperty(tmp, *manager, "some-server", Orthanc::GlobalProperty_DatabaseInternal8)); + ASSERT_EQ(longProperty, tmp); } manager->Close();
--- a/MySQL/NEWS Mon Jun 28 15:34:49 2021 +0200 +++ b/MySQL/NEWS Wed Jun 30 08:19:52 2021 +0200 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* Fix serialization of large jobs + Release 4.0 (2021-04-23) ========================
--- a/MySQL/Plugins/MySQLIndex.cpp Mon Jun 28 15:34:49 2021 +0200 +++ b/MySQL/Plugins/MySQLIndex.cpp Wed Jun 30 08:19:52 2021 +0200 @@ -261,26 +261,44 @@ t.Commit(); } - - if (revision != 5) + + if (revision == 5) + { + // Added new table "ServerProperties" since release 4.0 to deal with multiple writers + DatabaseManager::Transaction t(manager, TransactionType_ReadWrite); + + if (t.GetDatabaseTransaction().DoesTableExist("ServerProperties")) + { + /** + * Patch for MySQL plugin 4.0, where the column "value" was + * "TEXT" instead of "LONGTEXT", which prevented + * serialization of large jobs. This was giving error "MySQL + * error (1406,22001): Data too long for column 'value' at + * row 1" after log message "Serializing the content of the + * jobs engine" (in --trace mode). + * https://groups.google.com/g/orthanc-users/c/1Y3nTBdr0uE/m/K7PA5pboAgAJ + **/ + t.GetDatabaseTransaction().ExecuteMultiLines("ALTER TABLE ServerProperties MODIFY value LONGTEXT"); + } + else + { + t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server VARCHAR(64) NOT NULL, " + "property INTEGER, value LONGTEXT, PRIMARY KEY(server, property))"); + } + + // Revision 6 indicates that "value" of "ServerProperties" is + // "LONGTEXT", whereas revision 5 corresponds to "TEXT" + revision = 6; + SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision); + + t.Commit(); + } + + if (revision != 6) { LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision; throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); } - - - { - // New in release 4.0 to deal with multiple writers - DatabaseManager::Transaction t(manager, TransactionType_ReadWrite); - - if (!t.GetDatabaseTransaction().DoesTableExist("ServerProperties")) - { - t.GetDatabaseTransaction().ExecuteMultiLines("CREATE TABLE ServerProperties(server VARCHAR(64) NOT NULL, " - "property INTEGER, value TEXT, PRIMARY KEY(server, property))"); - } - - t.Commit(); - } }