chore: allow calling Context::ReportError from I/O dispatch fiber (#3182)

Fixes the issue when we are trying to Report the error from JournalStreamer::OnCompletion
that is called from a proactor callback directly from the I/O fiber.

We can not use fiber mutexes in the I/O fiber so we switch to regular mutex and reduce its critical sections
as much as possible.

Should fix the following failure:
2628431732 (step):6:622

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-06-17 10:58:24 +03:00 committed by GitHub
parent 8d82581c96
commit e6a9e0dbc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 12 deletions

View file

@ -279,12 +279,12 @@ class Context : protected Cancellation {
// Report error.
GenericError ReportErrorInternal(GenericError&& err);
private:
GenericError err_;
mutable util::fb2::Mutex mu_;
ErrHandler err_handler_;
util::fb2::Fiber err_handler_fb_;
// We use regular mutexes to be able to call ReportError directly from I/O callbacks.
mutable std::mutex err_mu_; // protects err_ and err_handler_
};
struct ScanOpts {