|
32 | 32 | #include "common/homestore_config.hpp" |
33 | 33 | #include "common/homestore_utils.hpp" |
34 | 34 | #include "common/crash_simulator.hpp" |
| 35 | +#include "replication/service/generic_repl_svc.h" |
35 | 36 |
|
36 | 37 | namespace homestore { |
37 | 38 |
|
@@ -582,13 +583,26 @@ void LogDev::on_flush_completion(LogGroup* lg) { |
582 | 583 | // since we support out-of-order lsn write, so no need to guarantee the order of logstore write completion |
583 | 584 | for (auto const& [idx, req] : req_map) { |
584 | 585 | m_pending_callback++; |
585 | | - iomanager.run_on_forget(iomgr::reactor_regex::random_worker, /* iomgr::fiber_regex::syncio_only, */ |
586 | | - [this, dev_offset, idx, req]() { |
587 | | - auto ld_key = logdev_key{idx, dev_offset}; |
588 | | - auto comp_cb = req->log_store->get_comp_cb(); |
589 | | - (req->cb) ? req->cb(req, ld_key) : comp_cb(req, ld_key); |
590 | | - m_pending_callback--; |
591 | | - }); |
| 586 | + auto callback_lambda = [this, dev_offset, idx, req]() { |
| 587 | + auto ld_key = logdev_key{idx, dev_offset}; |
| 588 | + auto comp_cb = req->log_store->get_comp_cb(); |
| 589 | + (req->cb) ? req->cb(req, ld_key) : comp_cb(req, ld_key); |
| 590 | + m_pending_callback--; |
| 591 | + }; |
| 592 | + |
| 593 | + // Only server side replication which uses raft runs the callback on a random worker. |
| 594 | + bool server_side_replication = true; |
| 595 | + if (hs()->has_repl_data_service()) { |
| 596 | + auto& repl_svc = dynamic_cast< GenericReplService& >(hs()->repl_service()); |
| 597 | + server_side_replication = repl_svc.get_impl_type() == repl_impl_type::server_side; |
| 598 | + } |
| 599 | + |
| 600 | + if (server_side_replication) { |
| 601 | + iomanager.run_on_forget(iomgr::reactor_regex::random_worker, /* iomgr::fiber_regex::syncio_only, */ |
| 602 | + [this, callback_lambda]() { callback_lambda(); }); |
| 603 | + } else { |
| 604 | + callback_lambda(); |
| 605 | + } |
592 | 606 | } |
593 | 607 | } |
594 | 608 |
|
|
0 commit comments