commitlog: fix flushing an entry marked as "sync" in periodic mode

After 546556b71b we can have mixed writes into commitlog,
some do flush immediately some do not. If non flushing write races with
flushing one and becomes responsible for writing back its buffer into a
file flush will be skipped which will cause assert in batch_cycle() to
trigger since flush position will not be advanced. Fix that by checking
that flush was skipped and in this case flush explicitly our file
position.

Fixes #5670

Message-Id: <20200128145103.GI26048@scylladb.com>
This commit is contained in:
Gleb Natapov
2020-01-28 16:51:03 +02:00
committed by Avi Kivity
parent f2feeb4b10
commit c654ffe34b

View File

@@ -806,7 +806,12 @@ public:
// (Note: wait_for_pending(pos) waits for operation _at_ pos (and before),
replay_position rp(me->_desc.id, position_type(fp));
return me->_pending_ops.wait_for_pending(rp, timeout).then([me, fp] {
assert(me->_flush_pos > fp);
assert(me->_segment_manager->cfg.mode != sync_mode::BATCH || me->_flush_pos > fp);
if (me->_flush_pos <= fp) {
// previous op we were waiting for was not sync one, so it did not flush
// force flush here
return me->do_flush(fp);
}
return make_ready_future<sseg_ptr>(me);
});
}