# HG changeset patch # User Alain Mazy # Date 1704896703 -3600 # Node ID cec6a0cd399f5b19298fef89e48cc9f962a7698f # Parent 2ca939d02d39047390db40c29bc893b4c4a11f63 now logging DatabaseCannotSerialize as a warning only with the details (Orthanc will log it as an error after all retries) diff -r 2ca939d02d39 -r cec6a0cd399f Framework/Common/DatabaseManager.cpp --- a/Framework/Common/DatabaseManager.cpp Wed Jan 10 15:22:40 2024 +0100 +++ b/Framework/Common/DatabaseManager.cpp Wed Jan 10 15:25:03 2024 +0100 @@ -493,7 +493,7 @@ default: // LOG(ERROR) << value.GetType(); - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "The returned field is not of the correct type (Integer64)"); } } } @@ -511,8 +511,7 @@ if (value != static_cast(static_cast(value))) { - LOG(ERROR) << "Integer overflow"; - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Integer overflow"); } else { @@ -546,8 +545,7 @@ return dynamic_cast(value).GetContent(); default: - //LOG(ERROR) << value.Format(); - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "The returned field is not of the correct type (String)"); } } diff -r 2ca939d02d39 -r cec6a0cd399f Framework/Plugins/DatabaseBackendAdapterV4.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Wed Jan 10 15:22:40 2024 +0100 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Wed Jan 10 15:25:03 2024 +0100 @@ -1350,7 +1350,14 @@ } catch (::Orthanc::OrthancException& e) { - LOG(ERROR) << "Exception in database back-end: " << e.What(); + if (e.GetErrorCode() == ::Orthanc::ErrorCode_DatabaseCannotSerialize) + { + LOG(WARNING) << "An SQL transaction failed and will likely be retried: " << e.GetDetails(); + } + else + { + LOG(ERROR) << "Exception in database back-end: " << e.What(); + } return static_cast(e.GetErrorCode()); } catch (::std::runtime_error& e) diff -r 2ca939d02d39 -r cec6a0cd399f Framework/PostgreSQL/PostgreSQLStatement.cpp --- a/Framework/PostgreSQL/PostgreSQLStatement.cpp Wed Jan 10 15:22:40 2024 +0100 +++ b/Framework/PostgreSQL/PostgreSQLStatement.cpp Wed Jan 10 15:25:03 2024 +0100 @@ -287,7 +287,8 @@ } #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) - throw Orthanc::OrthancException(Orthanc::ErrorCode_DatabaseCannotSerialize); + std::string errorString(PQresultErrorMessage(result)); + throw Orthanc::OrthancException(Orthanc::ErrorCode_DatabaseCannotSerialize, errorString, false); // don't log here, it is handled at higher level #else throw Orthanc::OrthancException(Orthanc::ErrorCode_Database, "Collision between multiple writers"); #endif diff -r 2ca939d02d39 -r cec6a0cd399f TODO --- a/TODO Wed Jan 10 15:22:40 2024 +0100 +++ b/TODO Wed Jan 10 15:25:03 2024 +0100 @@ -10,8 +10,6 @@ * Performance of joins in LookupResources: Create cached statement for LookupResources, that are grouped to search up to, say, 10 tags, instead of recompiling for each request -* Do not log "DatabaseCannotSerialize" errors in the plugin but only - in Orthanc after all retries have been made. --------------------- Common - Storage area