@@ -2568,7 +2568,8 @@ auto Series::openIterationIfDirty(IterationIndex_t index, Iteration iteration)
25682568 {
25692569 return IterationOpened::RemainsClosed;
25702570 }
2571- bool const dirtyRecursive = iteration.dirtyRecursive ();
2571+ bool dirtyRecursive = iteration.dirtyRecursive ();
2572+
25722573 if (iteration.get ().m_closed == internal::CloseStatus::ClosedInBackend)
25732574 {
25742575 // file corresponding with the iteration has previously been
@@ -2589,6 +2590,33 @@ auto Series::openIterationIfDirty(IterationIndex_t index, Iteration iteration)
25892590 return IterationOpened::RemainsClosed;
25902591 }
25912592
2593+ /*
2594+ * When using writeIterations(), the currently active Iteration should
2595+ * always be flushed (unless, as checked above, it is already closed).
2596+ * These two blocks checks if an Iteration is currently collectively opened.
2597+ */
2598+ auto &series = get ();
2599+ [&]() {
2600+ if (!series.m_sharedStatefulIterator )
2601+ {
2602+ return ;
2603+ }
2604+ auto const current_iteration =
2605+ series.m_sharedStatefulIterator ->peekCurrentIteration ();
2606+ dirtyRecursive |=
2607+ current_iteration.has_value () && *current_iteration == index;
2608+ }();
2609+ [&]() {
2610+ if (!series.m_writeIterations )
2611+ {
2612+ return ;
2613+ }
2614+ auto const current_iteration =
2615+ series.m_writeIterations ->currentIterationIndex ();
2616+ dirtyRecursive |=
2617+ current_iteration.has_value () && *current_iteration == index;
2618+ }();
2619+
25922620 switch (iterationEncoding ())
25932621 {
25942622 using IE = IterationEncoding;
0 commit comments