Currently, maybe_switch_to_new_writer resets _current_writer
only in a continuation after closing the current writer.
This leaves a window of vulnerability if close() yields,
and token_group_based_splitting_mutation_writer::close()
is called. Seeing the engaged _current_writer, close()
will call _current_writer->close() - which must be called
exactly once.
Solve this when switching to a new writer by resetting
_current_writer before closing it and potentially yielding.
Fixes #22715
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
Closes scylladb/scylladb#22922
(cherry picked from commit 29b795709b)
Closes scylladb/scylladb#22965