Skip to content

Commit

Permalink
[fix] warmup to mem error
Browse files Browse the repository at this point in the history
It turns out that mem and disk are not separated, the storage of mem is
asynchronous, and the storage of disk is synchronous, so when it is
deleted later, it is generally written. Later, after the separation of
the two, an exception occurred in the asynchronous save of mem.

Signed-off-by: Cyber-SiKu <[email protected]>
  • Loading branch information
Cyber-SiKu committed Jun 27, 2023
1 parent d436082 commit 597e5bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
22 changes: 12 additions & 10 deletions curvefs/src/client/warmup/warmup_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,14 @@ void WarmupManagerS3Impl::WarmUpAllObjs(
}
if (context->retCode == 0) {
VLOG(9) << "Get Object success: " << context->key;
PutObjectToCache(key, context->key, context->buf, context->len);
PutObjectToCache(key, context);
CollectMetrics(&warmupS3Metric_.warmupS3Cached, context->len,
start);
warmupS3Metric_.warmupS3CacheSize << context->len;
if (pendingReq.fetch_sub(1, std::memory_order_seq_cst) == 1) {
VLOG(6) << "pendingReq is over";
cond.Signal();
}
delete[] context->buf;
return;
}
warmupS3Metric_.warmupS3Cached.eps.count << 1;
Expand Down Expand Up @@ -678,9 +677,8 @@ void WarmupManagerS3Impl::AddFetchS3objectsTask(fuse_ino_t key,
}
}

void WarmupManagerS3Impl::PutObjectToCache(fuse_ino_t key,
const std::string &filename,
const char *data, uint64_t len) {
void WarmupManagerS3Impl::PutObjectToCache(
fuse_ino_t key, const std::shared_ptr<GetObjectAsyncContext> &context) {
ReadLockGuard lock(inode2ProgressMutex_);
auto iter = FindWarmupProgressByKeyLocked(key);
if (iter == inode2Progress_.end()) {
Expand All @@ -692,17 +690,21 @@ void WarmupManagerS3Impl::PutObjectToCache(fuse_ino_t key,
iter->second.FinishedPlusOne();
switch (iter->second.GetStorageType()) {
case curvefs::client::common::WarmupStorageType::kWarmupStorageTypeDisk:
ret = s3Adaptor_->GetDiskCacheManager()->WriteReadDirect(filename, data,
len);
ret = s3Adaptor_->GetDiskCacheManager()->WriteReadDirect(
context->key, context->buf, context->len);
if (ret < 0) {
LOG_EVERY_SECOND(INFO)
<< "write read directly failed, key: " << filename;
<< "write read directly failed, key: " << context->key;
}
delete[] context->buf;
break;
case curvefs::client::common::WarmupStorageType::kWarmupStorageTypeKvClient:
if (kvClientManager_ != nullptr) {
kvClientManager_->Set(
std::make_shared<SetKVCacheTask>(filename, data, len));
kvClientManager_->Set(std::make_shared<SetKVCacheTask>(
context->key, context->buf, context->len,
[context](const std::shared_ptr<SetKVCacheTask> &) {
delete[] context->buf;
}));
}
break;
default:
Expand Down
5 changes: 3 additions & 2 deletions curvefs/src/client/warmup/warmup_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ class WarmupManagerS3Impl : public WarmupManager {

void AddFetchS3objectsTask(fuse_ino_t key, std::function<void()> task);

void PutObjectToCache(fuse_ino_t key, const std::string &filename,
const char *data, uint64_t len);
void
PutObjectToCache(fuse_ino_t key,
const std::shared_ptr<GetObjectAsyncContext> &context);

protected:
std::deque<WarmupFilelist> warmupFilelistDeque_;
Expand Down

0 comments on commit 597e5bc

Please sign in to comment.