Mercurial > hg > orthanc
changeset 5919:0385c30d4ca2 find-refactoring tip
housekeeping thread is now managed at the database plugin level
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 11 Dec 2024 15:32:11 +0100 |
parents | 2c3f3f3da26d |
children | |
files | NEWS OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto OrthancServer/Sources/Database/BaseCompatibilityTransaction.cpp OrthancServer/Sources/Database/BaseCompatibilityTransaction.h OrthancServer/Sources/Database/IDatabaseWrapper.h OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.h OrthancServer/Sources/ServerIndex.cpp OrthancServer/Sources/ServerIndex.h |
diffstat | 10 files changed, 2 insertions(+), 136 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Tue Dec 10 10:28:15 2024 +0100 +++ b/NEWS Wed Dec 11 15:32:11 2024 +0100 @@ -60,9 +60,6 @@ * DICOM TLS: "DicomTlsTrustedCertificates" is not required anymore when issuing an outgoing SCU connexion when "DicomTlsRemoteCertificateRequired" is set to false. -* Introduced a new thread to perform DB Housekeeping at regular interval (1s) for the - DB plugins requiring it (currently only PostgreSQL). E.g: This avoids very long update - times in case you don't call /statistics for a long period. * Fix C-Find queries not returning computed tags like ModalitiesInStudy, NumberOfStudyRelatedSeries, ... in very specific use-cases. * Fix C-Find queries not returning private tags in the modality worklist plugin.
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Wed Dec 11 15:32:11 2024 +0100 @@ -1063,12 +1063,6 @@ uncompressedSize = response.update_and_get_statistics().total_uncompressed_size(); } - virtual void PerformDbHousekeeping() ORTHANC_OVERRIDE - { - DatabasePluginMessages::TransactionResponse response; - ExecuteTransaction(response, DatabasePluginMessages::OPERATION_PERFORM_DB_HOUSEKEEPING); - } - virtual bool LookupMetadata(std::string& target, int64_t& revision, int64_t id, @@ -1891,7 +1885,6 @@ dbCapabilities_.SetMeasureLatency(systemInfo.has_measure_latency()); dbCapabilities_.SetHasExtendedChanges(systemInfo.has_extended_changes()); dbCapabilities_.SetHasFindSupport(systemInfo.supports_find()); - dbCapabilities_.SetHasDbHousekeeping(systemInfo.has_db_housekeeping()); } open_ = true;
--- a/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto Wed Dec 11 15:32:11 2024 +0100 @@ -160,7 +160,6 @@ bool has_measure_latency = 7; bool supports_find = 8; // New in Orthanc 1.12.5 bool has_extended_changes = 9; // New in Orthanc 1.12.5 - bool has_db_housekeeping = 10; // New in Orthanc 1.12.5 } } @@ -316,7 +315,6 @@ OPERATION_FIND = 50; // New in Orthanc 1.12.5 OPERATION_GET_CHANGES_EXTENDED = 51; // New in Orthanc 1.12.5 OPERATION_COUNT_RESOURCES = 52; // New in Orthanc 1.12.5 - OPERATION_PERFORM_DB_HOUSEKEEPING = 53; // New in Orthanc 1.12.5 } message Rollback { @@ -707,13 +705,6 @@ } } -message PerformDbHousekeeping { - message Request { - } - message Response { - } -} - message ClearMainDicomTags { message Request { int64 id = 1; @@ -1042,7 +1033,6 @@ Find.Request find = 150; GetChangesExtended.Request get_changes_extended = 151; Find.Request count_resources = 152; - PerformDbHousekeeping.Request perform_db_housekeeping = 153; } message TransactionResponse { @@ -1096,10 +1086,9 @@ ListLabels.Response list_labels = 147; IncrementGlobalProperty.Response increment_global_property = 148; UpdateAndGetStatistics.Response update_and_get_statistics = 149; - repeated Find.Response find = 150; // One message per found resources + repeated Find.Response find = 150; // One message per found resource GetChangesExtended.Response get_changes_extended = 151; CountResources.Response count_resources = 152; - PerformDbHousekeeping.Response perform_db_housekeeping = 153; } enum RequestType {
--- a/OrthancServer/Sources/Database/BaseCompatibilityTransaction.cpp Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Sources/Database/BaseCompatibilityTransaction.cpp Wed Dec 11 15:32:11 2024 +0100 @@ -45,11 +45,6 @@ throw OrthancException(ErrorCode_NotImplemented); // Not supported } - void BaseCompatibilityTransaction::PerformDbHousekeeping() - { - throw OrthancException(ErrorCode_NotImplemented); // Not supported - } - void BaseCompatibilityTransaction::GetChangesExtended(std::list<ServerIndexChange>& target /*out*/, bool& done /*out*/, int64_t since,
--- a/OrthancServer/Sources/Database/BaseCompatibilityTransaction.h Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Sources/Database/BaseCompatibilityTransaction.h Wed Dec 11 15:32:11 2024 +0100 @@ -48,8 +48,6 @@ int64_t& compressedSize, int64_t& uncompressedSize) ORTHANC_OVERRIDE; - virtual void PerformDbHousekeeping() ORTHANC_OVERRIDE; - virtual void ExecuteCount(uint64_t& count, const FindRequest& request, const IDatabaseWrapper::Capabilities& capabilities) ORTHANC_OVERRIDE;
--- a/OrthancServer/Sources/Database/IDatabaseWrapper.h Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Sources/Database/IDatabaseWrapper.h Wed Dec 11 15:32:11 2024 +0100 @@ -56,7 +56,6 @@ bool hasMeasureLatency_; bool hasFindSupport_; bool hasExtendedChanges_; - bool hasDbHousekeeping_; public: Capabilities() : @@ -67,8 +66,7 @@ hasUpdateAndGetStatistics_(false), hasMeasureLatency_(false), hasFindSupport_(false), - hasExtendedChanges_(false), - hasDbHousekeeping_(false) + hasExtendedChanges_(false) { } @@ -132,16 +130,6 @@ return hasUpdateAndGetStatistics_; } - void SetHasDbHousekeeping(bool value) - { - hasDbHousekeeping_ = value; - } - - bool HasDbHousekeeping() const - { - return hasDbHousekeeping_; - } - void SetMeasureLatency(bool value) { hasMeasureLatency_ = value; @@ -402,9 +390,6 @@ int64_t to, uint32_t limit, const std::set<ChangeType>& filterType) = 0; - - // New in Orthanc 1.12.5 - virtual void PerformDbHousekeeping() = 0; };
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Wed Dec 11 15:32:11 2024 +0100 @@ -3307,24 +3307,4 @@ } } } - - void StatelessDatabaseOperations::PerformDbHousekeeping() - { - class Operations : public IReadWriteOperations - { - public: - Operations() - { - } - - virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE - { - transaction.PerformDbHousekeeping(); - } - }; - - Operations operations; - Apply(operations); - } - }
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Wed Dec 11 15:32:11 2024 +0100 @@ -388,11 +388,6 @@ return transaction_.UpdateAndGetStatistics(patientsCount, studiesCount, seriesCount, instancesCount, compressedSize, uncompressedSize); } - void PerformDbHousekeeping() - { - return transaction_.PerformDbHousekeeping(); - } - void SetMetadata(int64_t id, MetadataType type, const std::string& value, @@ -729,8 +724,5 @@ void ExecuteCount(uint64_t& count, const FindRequest& request); - - void PerformDbHousekeeping(); - }; }
--- a/OrthancServer/Sources/ServerIndex.cpp Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Sources/ServerIndex.cpp Wed Dec 11 15:32:11 2024 +0100 @@ -266,46 +266,6 @@ } }; - void ServerIndex::PerformDbHouskeeping(ServerIndex* that, - unsigned int threadSleepGranularityMilliseconds) - { - Logging::SetCurrentThreadName("DB-HK"); - - static const unsigned int SLEEP_SECONDS = 1; - - if (threadSleepGranularityMilliseconds > 1000) - { - throw OrthancException(ErrorCode_ParameterOutOfRange); - } - - LOG(INFO) << "Starting the DB Housekeeping thread (sleep = " << SLEEP_SECONDS << " seconds)"; - - unsigned int count = 0; - unsigned int countThreshold = (1000 * SLEEP_SECONDS) / threadSleepGranularityMilliseconds; - - while (!that->done_) - { - boost::this_thread::sleep(boost::posix_time::milliseconds(threadSleepGranularityMilliseconds)); - count++; - - if (count >= countThreshold) - { - try - { - that->PerformDbHousekeeping(); - } - catch (...) - { - LOG(ERROR) << "Error while performing DB Housekeeping"; - } - - count = 0; - } - } - - LOG(INFO) << "Stopping the DB Housekeeping thread"; - } - void ServerIndex::FlushThread(ServerIndex* that, unsigned int threadSleepGranularityMilliseconds) { @@ -383,20 +343,6 @@ } } - // For some DB plugins, some housekeeping might be required at regular interval - // like computing the statistics or update some tables after an upgrade - if (GetDatabaseCapabilities().HasDbHousekeeping()) - { - if (readOnly) - { - LOG(WARNING) << "READ-ONLY SYSTEM: not starting the DB Housekeeping thread"; - } - else - { - dbHousekeepingThread_ = boost::thread(PerformDbHouskeeping, this, threadSleepGranularityMilliseconds); - } - } - if (readOnly) { LOG(WARNING) << "READ-ONLY SYSTEM: not starting the unstable resources monitor thread"; @@ -430,11 +376,6 @@ flushThread_.join(); } - if (dbHousekeepingThread_.joinable()) - { - dbHousekeepingThread_.join(); - } - if (unstableResourcesMonitorThread_.joinable()) { unstableResourcesMonitorThread_.join();
--- a/OrthancServer/Sources/ServerIndex.h Tue Dec 10 10:28:15 2024 +0100 +++ b/OrthancServer/Sources/ServerIndex.h Wed Dec 11 15:32:11 2024 +0100 @@ -42,7 +42,6 @@ bool done_; boost::mutex monitoringMutex_; boost::thread flushThread_; - boost::thread dbHousekeepingThread_; boost::thread unstableResourcesMonitorThread_; LeastRecentlyUsedIndex<std::pair<ResourceType, int64_t>, UnstableResourcePayload> unstableResources_; @@ -55,9 +54,6 @@ static void FlushThread(ServerIndex* that, unsigned int threadSleep); - static void PerformDbHouskeeping(ServerIndex* that, - unsigned int threadSleep); - static void UnstableResourcesMonitorThread(ServerIndex* that, unsigned int threadSleep);