Mercurial > hg > orthanc-databases
changeset 747:176e5dfbad43
revert: check revision inside the transaction AND outside
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Wed, 08 Oct 2025 14:47:15 +0200 |
| parents | fc41dc504073 |
| children | 97cfbcf1a35a 5295d495a114 |
| files | PostgreSQL/Plugins/PostgreSQLIndex.cpp |
| diffstat | 1 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/PostgreSQL/Plugins/PostgreSQLIndex.cpp Wed Oct 08 12:48:04 2025 +0200 +++ b/PostgreSQL/Plugins/PostgreSQLIndex.cpp Wed Oct 08 14:47:15 2025 +0200 @@ -273,8 +273,22 @@ LOG(WARNING) << "Upgrading DB schema by applying PrepareIndex.sql"; // apply all idempotent changes that are in the PrepareIndex.sql ApplyPrepareIndex(t, manager); + + // first check that the patch level has been upgraded correctly before we commit the transaction ! + if (!LookupGlobalIntegerProperty(currentRevision, manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel)) + { + LOG(ERROR) << "No Database revision found after the upgrade !"; + throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); + } + + LOG(WARNING) << "Database revision after the upgrade (1) is " << currentRevision; + + if (currentRevision != CURRENT_DB_REVISION) + { + LOG(ERROR) << "Invalid database revision after the upgrade (1) !"; + throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); + } } - } t.Commit(); @@ -288,12 +302,12 @@ if (!LookupGlobalIntegerProperty(currentRevision, manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel)) { - LOG(ERROR) << "No Database revision found after the upgrade !"; + LOG(ERROR) << "No Database revision found after the upgrade (2) !"; throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); } LookupGlobalIntegerProperty(currentRevision, manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel); - LOG(WARNING) << "Database revision after the upgrade is " << currentRevision; + LOG(WARNING) << "Database revision after the upgrade (2) is " << currentRevision; if (currentRevision != CURRENT_DB_REVISION) {
