diff --git a/services/backup/docker-server/contents/server/src/Reactors/client/blob/BlobGetClientReactor.h b/services/backup/docker-server/contents/server/src/Reactors/client/blob/BlobGetClientReactor.h --- a/services/backup/docker-server/contents/server/src/Reactors/client/blob/BlobGetClientReactor.h +++ b/services/backup/docker-server/contents/server/src/Reactors/client/blob/BlobGetClientReactor.h @@ -40,8 +40,7 @@ std::unique_ptr BlobGetClientReactor::readResponse(blob::GetResponse &response) { if (!this->dataChunks->write(std::move(*response.mutable_datachunk()))) { - throw std::runtime_error( - "error reading compaction data from the blob service"); + throw std::runtime_error("error reading data from the blob service"); } return nullptr; } diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h @@ -63,12 +63,10 @@ throw std::runtime_error( "get reactor cannot be initialized when backup item is missing"); } - if (this->getReactor == nullptr) { - this->getReactor = std::make_shared( - holder, this->dataChunks); - this->getReactor->request.set_holder(holder); - this->blobClient.get(this->getReactor); - } + this->getReactor.reset( + new reactor::BlobGetClientReactor(holder, this->dataChunks)); + this->getReactor->request.set_holder(holder); + this->blobClient.get(this->getReactor); } void PullBackupReactor::initialize() { @@ -99,7 +97,9 @@ // as there may be multiple threads from the pool taking over here const std::lock_guard lock(this->reactorStateMutex); if (this->state == State::COMPACTION) { - this->initializeGetReactor(this->backupItem->getCompactionHolder()); + if (this->getReactor == nullptr) { + this->initializeGetReactor(this->backupItem->getCompactionHolder()); + } std::string dataChunk; this->dataChunks->blockingRead(dataChunk); if (!dataChunk.empty()) { @@ -110,7 +110,9 @@ throw std::runtime_error( "dangling data discovered after reading compaction"); } - this->getReactor = nullptr; + if (!this->getReactor->getStatus().ok()) { + throw std::runtime_error(this->getReactor->getStatus().error_message()); + } this->state = State::LOGS; } if (this->state == State::LOGS) { @@ -119,6 +121,9 @@ return std::make_unique(grpc::Status::OK); } if (this->currentLogIndex == this->logs.size()) { + if (!this->dataChunks->isEmpty()) { + throw std::runtime_error("dangling data discovered after reading logs"); + } return std::make_unique(grpc::Status::OK); } if (this->currentLogIndex > this->logs.size()) { @@ -137,9 +142,13 @@ } std::string dataChunk; this->dataChunks->blockingRead(dataChunk); + if (!this->getReactor->getStatus().ok()) { + throw std::runtime_error(this->getReactor->getStatus().error_message()); + } if (dataChunk.empty()) { ++this->currentLogIndex; this->currentLog = nullptr; + return nullptr; } else { response->set_logchunk(dataChunk); } diff --git a/services/blob/src/Reactors/server/GetReactor.h b/services/blob/src/Reactors/server/GetReactor.h --- a/services/blob/src/Reactors/server/GetReactor.h +++ b/services/blob/src/Reactors/server/GetReactor.h @@ -38,7 +38,7 @@ std::min(this->chunkSize, this->fileSize - this->offset); std::string range = "bytes=" + std::to_string(this->offset) + "-" + - std::to_string(this->offset + nextSize); + std::to_string(this->offset + nextSize - 1); this->getRequest.SetRange(range); Aws::S3::Model::GetObjectOutcome getOutcome =