mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix(replication): Handle errors instead of crashing. (#1757)
This commit is contained in:
parent
d964325f93
commit
254c86786e
2 changed files with 9 additions and 2 deletions
|
@ -106,7 +106,11 @@ std::error_code JournalReader::EnsureRead(size_t num) {
|
||||||
// Try reading at least how much we need, but possibly more
|
// Try reading at least how much we need, but possibly more
|
||||||
uint64_t read;
|
uint64_t read;
|
||||||
SET_OR_RETURN(source_->ReadAtLeast(buf_.AppendBuffer(), remainder), read);
|
SET_OR_RETURN(source_->ReadAtLeast(buf_.AppendBuffer(), remainder), read);
|
||||||
CHECK(read >= remainder);
|
|
||||||
|
// Happens on end of stream (for example, a too-small string buffer or a closed socket)
|
||||||
|
if (read < remainder) {
|
||||||
|
return make_error_code(errc::io_error);
|
||||||
|
}
|
||||||
|
|
||||||
buf_.CommitWrite(read);
|
buf_.CommitWrite(read);
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -666,7 +666,10 @@ error_code DflyShardReplica::StartStableSyncFlow(Context* cntx) {
|
||||||
ProactorBase* mythread = ProactorBase::me();
|
ProactorBase* mythread = ProactorBase::me();
|
||||||
CHECK(mythread);
|
CHECK(mythread);
|
||||||
|
|
||||||
CHECK(Sock()->IsOpen());
|
if (!Sock()->IsOpen()) {
|
||||||
|
return std::make_error_code(errc::io_error);
|
||||||
|
}
|
||||||
|
|
||||||
sync_fb_ =
|
sync_fb_ =
|
||||||
fb2::Fiber("shard_stable_sync_read", &DflyShardReplica::StableSyncDflyReadFb, this, cntx);
|
fb2::Fiber("shard_stable_sync_read", &DflyShardReplica::StableSyncDflyReadFb, this, cntx);
|
||||||
if (use_multi_shard_exe_sync_) {
|
if (use_multi_shard_exe_sync_) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue