Mercurial > hg > orthanc-databases
changeset 445:cec6a0cd399f pg-transactions
now logging DatabaseCannotSerialize as a warning only with the details (Orthanc will log it as an error after all retries)
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 10 Jan 2024 15:25:03 +0100 |
parents | 2ca939d02d39 |
children | 9e039e65d68e |
files | Framework/Common/DatabaseManager.cpp Framework/Plugins/DatabaseBackendAdapterV4.cpp Framework/PostgreSQL/PostgreSQLStatement.cpp TODO |
diffstat | 4 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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<int64_t>(static_cast<int32_t>(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<const Utf8StringValue&>(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)"); } }
--- 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<OrthancPluginErrorCode>(e.GetErrorCode()); } catch (::std::runtime_error& e)
--- 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
--- 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