Fix flusher possibly not trimming journal on rollback

antietcd
Vitaliy Filippov 2024-04-05 23:14:39 +03:00
parent 5d3aaf016b
commit a2994ecd0d
2 changed files with 6 additions and 2 deletions

View File

@ -86,6 +86,8 @@ void journal_flusher_t::loop()
cur_flusher_count--; cur_flusher_count--;
} }
} }
if (trim_wanted)
co[0].try_trim = true;
for (int i = 0; (active_flushers > 0 || dequeuing || trim_wanted > 0) && i < cur_flusher_count; i++) for (int i = 0; (active_flushers > 0 || dequeuing || trim_wanted > 0) && i < cur_flusher_count; i++)
co[i].loop(); co[i].loop();
} }
@ -364,10 +366,10 @@ resume_0:
!flusher->flush_queue.size() || !flusher->dequeuing) !flusher->flush_queue.size() || !flusher->dequeuing)
{ {
stop_flusher: stop_flusher:
if (flusher->trim_wanted > 0 && cur.oid.inode != 0) if (flusher->trim_wanted > 0 && try_trim)
{ {
// Attempt forced trim // Attempt forced trim
cur.oid = {}; try_trim = false;
flusher->active_flushers++; flusher->active_flushers++;
goto trim_journal; goto trim_journal;
} }
@ -375,6 +377,7 @@ stop_flusher:
wait_state = 0; wait_state = 0;
return true; return true;
} }
try_trim = true;
cur.oid = flusher->flush_queue.front(); cur.oid = flusher->flush_queue.front();
cur.version = flusher->flush_versions[cur.oid]; cur.version = flusher->flush_versions[cur.oid];
flusher->flush_queue.pop_front(); flusher->flush_queue.pop_front();

View File

@ -60,6 +60,7 @@ class journal_flusher_co
std::map<object_id, uint64_t>::iterator repeat_it; std::map<object_id, uint64_t>::iterator repeat_it;
std::function<void(ring_data_t*)> simple_callback_r, simple_callback_rj, simple_callback_w; std::function<void(ring_data_t*)> simple_callback_r, simple_callback_rj, simple_callback_w;
bool try_trim = false;
bool skip_copy, has_delete, has_writes; bool skip_copy, has_delete, has_writes;
std::vector<copy_buffer_t> v; std::vector<copy_buffer_t> v;
std::vector<copy_buffer_t>::iterator it; std::vector<copy_buffer_t>::iterator it;