From f0a55f7996e9ea2c7824fd5ab136b7c1864bbcdd Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Wed, 24 Jan 2024 11:18:25 -0500 Subject: DynamicExtension: Fixed reconstruction trigger data race Tweak the reconstruction trigger code to ensure that multiple reconstructions won't be triggered at the same time. --- include/framework/DynamicExtension.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/framework/DynamicExtension.h b/include/framework/DynamicExtension.h index 89ee30f..40f137c 100644 --- a/include/framework/DynamicExtension.h +++ b/include/framework/DynamicExtension.h @@ -451,7 +451,7 @@ private: ((DynamicExtension *) args->extension)->advance_epoch(new_head); } - ((DynamicExtension *) args->extension)->m_reconstruction_scheduled = false; + ((DynamicExtension *) args->extension)->m_reconstruction_scheduled.store(false); delete args; } @@ -537,9 +537,12 @@ private: } int internal_append(const R &rec, bool ts) { - if (!m_reconstruction_scheduled.load() && m_buffer->is_at_low_watermark()) { - m_reconstruction_scheduled.store(true); - schedule_reconstruction(); + if (m_buffer->is_at_low_watermark()) { + auto old = false; + + if (m_reconstruction_scheduled.compare_exchange_strong(old, true)) { + schedule_reconstruction(); + } } /* this will fail if the HWM is reached and return 0 */ -- cgit v1.2.3