From e0e825756b82155a61be75a802bf2060d521ef0c Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Tue, 14 Jul 2026 13:31:49 -0500 Subject: [PATCH 1/6] Track released broadcast Fragments to not release the same twice --- artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc index c1d5106b..700007a3 100644 --- a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc +++ b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc @@ -93,6 +93,7 @@ class ArtdaqSharedMemoryService : public ArtdaqSharedMemoryServiceInterface private: std::unique_ptr incoming_events_; std::list> event_ordering_; + std::set released_broadcast_sequence_ids_; size_t read_timeout_; size_t subrun_closure_threshold_{1}; double safety_valve_timeout_s_{10.0}; @@ -309,9 +310,14 @@ std::shared_ptr ArtdaqSharedMemoryService::ReceiveEvent(bool broadc { // First Fragment is broadcast (begin/end run/subrun), but there's more in event ordering! TLOG(TLVL_RECEIVEEVENT) << "Returning Broadcast Fragment due to subrun closure"; - output_event = event_ordering_.front(); + + if (released_broadcast_sequence_ids_.count(event_ordering_.front()->header->sequence_id) == 0) + { + output_event = event_ordering_.front(); + released_broadcast_sequence_ids_.insert(event_ordering_.front()->header->sequence_id); + } event_ordering_.pop_front(); - break; // while(output_event == nullptr) + continue; // while(output_event == nullptr) } } else if (current_subrun_ != 0 && first_sr > current_subrun_ + 1) From 2bd864474650a9346d942da4c38cf58c5d82ad5c Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Tue, 14 Jul 2026 13:32:01 -0500 Subject: [PATCH 2/6] Clang-format --- artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc index 700007a3..d37d8228 100644 --- a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc +++ b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc @@ -311,9 +311,9 @@ std::shared_ptr ArtdaqSharedMemoryService::ReceiveEvent(bool broadc // First Fragment is broadcast (begin/end run/subrun), but there's more in event ordering! TLOG(TLVL_RECEIVEEVENT) << "Returning Broadcast Fragment due to subrun closure"; - if (released_broadcast_sequence_ids_.count(event_ordering_.front()->header->sequence_id) == 0) + if (released_broadcast_sequence_ids_.count(event_ordering_.front()->header->sequence_id) == 0) { - output_event = event_ordering_.front(); + output_event = event_ordering_.front(); released_broadcast_sequence_ids_.insert(event_ordering_.front()->header->sequence_id); } event_ordering_.pop_front(); From 8507830fb4775f27e5a65b009592355f3d87a987 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Wed, 15 Jul 2026 07:51:56 -0500 Subject: [PATCH 3/6] Limit list size --- artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc index d37d8228..ee473a22 100644 --- a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc +++ b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc @@ -315,6 +315,7 @@ std::shared_ptr ArtdaqSharedMemoryService::ReceiveEvent(bool broadc { output_event = event_ordering_.front(); released_broadcast_sequence_ids_.insert(event_ordering_.front()->header->sequence_id); + while (released_broadcast_sequence_ids_.size() > 1000) { released_broadcast_sequence_ids_.erase(released_broadcast_sequence_ids_.begin()); } } event_ordering_.pop_front(); continue; // while(output_event == nullptr) From 8c5e344ee3a546dd48a8a866c4d402a8c53e1256 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Wed, 15 Jul 2026 08:16:55 -0500 Subject: [PATCH 4/6] Print a warning message whenever broadcasts are discarded. Abort DataLogger and Dispatchers which do not set init_fragment_count --- artdaq/Application/DataLoggerCore.cc | 5 +++++ artdaq/Application/DispatcherCore.cc | 5 +++++ artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/artdaq/Application/DataLoggerCore.cc b/artdaq/Application/DataLoggerCore.cc index 7d5756ed..0fca2348 100644 --- a/artdaq/Application/DataLoggerCore.cc +++ b/artdaq/Application/DataLoggerCore.cc @@ -53,6 +53,11 @@ bool artdaq::DataLoggerCore::initialize(fhicl::ParameterSet const& pset) TLOG(50) << "In any case, if you are using multiple art analyzers, make sure to set \"shared_memory_ordering\" to false in the DataLogger configuration to avoid issues with events not being received by the art analyzers."; } + if (!agg_pset.has_key("init_fragment_count")) { + TLOG(TLVL_ERROR) << "ERROR: init_fragment_count must be set for the DataLogger to function properly. Please set `init_fragment_count: 0` in the DataLogger configuration. (Will be book-kept by DAQInterface)"; + return false; + } + // initialize the MetricManager and the names of our metrics fhicl::ParameterSet metric_pset = daq_pset.get("metrics", fhicl::ParameterSet()); diff --git a/artdaq/Application/DispatcherCore.cc b/artdaq/Application/DispatcherCore.cc index 56b6a478..6cc0d5ae 100644 --- a/artdaq/Application/DispatcherCore.cc +++ b/artdaq/Application/DispatcherCore.cc @@ -65,6 +65,11 @@ bool artdaq::DispatcherCore::initialize(fhicl::ParameterSet const& pset) return false; } + if (!agg_pset.has_key("init_fragment_count")) + { + TLOG(TLVL_ERROR) << "ERROR: init_fragment_count must be set for the Dispatcher to function properly. Please set `init_fragment_count: 0` in the Dispatcher configuration. (Will be book-kept by DAQInterface)"; + return false; + } broadcast_mode_ = agg_pset.get("broadcast_mode", true); allow_label_overwrites_ = agg_pset.get("allow_label_overwrites", true); if (broadcast_mode_ && !agg_pset.has_key("broadcast_mode")) diff --git a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc index ee473a22..efd26395 100644 --- a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc +++ b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc @@ -316,7 +316,10 @@ std::shared_ptr ArtdaqSharedMemoryService::ReceiveEvent(bool broadc output_event = event_ordering_.front(); released_broadcast_sequence_ids_.insert(event_ordering_.front()->header->sequence_id); while (released_broadcast_sequence_ids_.size() > 1000) { released_broadcast_sequence_ids_.erase(released_broadcast_sequence_ids_.begin()); } - } + } + else { + TLOG(TLVL_WARNING) << "Discarding duplicate Broadcast with sequence ID " << event_ordering_.front()->header->sequence_id << " and count " << event_ordering_.front()->fragments.size(); + } event_ordering_.pop_front(); continue; // while(output_event == nullptr) } From f6dd41d60f2b37335024bac7f957d92091ea290c Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Wed, 15 Jul 2026 08:18:07 -0500 Subject: [PATCH 5/6] clang-format --- artdaq/Application/DataLoggerCore.cc | 5 +++-- artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/artdaq/Application/DataLoggerCore.cc b/artdaq/Application/DataLoggerCore.cc index 0fca2348..91653bd1 100644 --- a/artdaq/Application/DataLoggerCore.cc +++ b/artdaq/Application/DataLoggerCore.cc @@ -53,10 +53,11 @@ bool artdaq::DataLoggerCore::initialize(fhicl::ParameterSet const& pset) TLOG(50) << "In any case, if you are using multiple art analyzers, make sure to set \"shared_memory_ordering\" to false in the DataLogger configuration to avoid issues with events not being received by the art analyzers."; } - if (!agg_pset.has_key("init_fragment_count")) { + if (!agg_pset.has_key("init_fragment_count")) + { TLOG(TLVL_ERROR) << "ERROR: init_fragment_count must be set for the DataLogger to function properly. Please set `init_fragment_count: 0` in the DataLogger configuration. (Will be book-kept by DAQInterface)"; return false; - } + } // initialize the MetricManager and the names of our metrics fhicl::ParameterSet metric_pset = daq_pset.get("metrics", fhicl::ParameterSet()); diff --git a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc index efd26395..3df30c69 100644 --- a/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc +++ b/artdaq/ArtModules/ArtdaqSharedMemoryService_service.cc @@ -316,10 +316,11 @@ std::shared_ptr ArtdaqSharedMemoryService::ReceiveEvent(bool broadc output_event = event_ordering_.front(); released_broadcast_sequence_ids_.insert(event_ordering_.front()->header->sequence_id); while (released_broadcast_sequence_ids_.size() > 1000) { released_broadcast_sequence_ids_.erase(released_broadcast_sequence_ids_.begin()); } - } - else { + } + else + { TLOG(TLVL_WARNING) << "Discarding duplicate Broadcast with sequence ID " << event_ordering_.front()->header->sequence_id << " and count " << event_ordering_.front()->fragments.size(); - } + } event_ordering_.pop_front(); continue; // while(output_event == nullptr) } From 23a188e00c7bfa9e8517c82f1c0a8fcdfc3f686e Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Wed, 15 Jul 2026 08:48:15 -0500 Subject: [PATCH 6/6] Make the Init Fragment message at run start an INFO --- artdaq/DAQrate/SharedMemoryEventManager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/artdaq/DAQrate/SharedMemoryEventManager.cc b/artdaq/DAQrate/SharedMemoryEventManager.cc index 43ce4095..7962ee95 100644 --- a/artdaq/DAQrate/SharedMemoryEventManager.cc +++ b/artdaq/DAQrate/SharedMemoryEventManager.cc @@ -1802,7 +1802,7 @@ void artdaq::SharedMemoryEventManager::send_init_frags_() } else if (init_fragment_count_ > 0 && init_fragment_map_size_() == 0) { - TLOG(TLVL_WARNING) << "Cannot send Init Fragment(s) because I haven't yet received them! Set send_init_fragments to false or init_fragment_count to 0 if this process does not receive serialized art events to avoid potentially lengthy timeouts!"; + TLOG(TLVL_INFO) << "Cannot send Init Fragment(s) because I haven't yet received any! Set send_init_fragments to false or init_fragment_count to 0 if this process does not receive serialized art events to avoid potentially lengthy timeouts!"; } else if (init_fragment_count_ > 0) {