Skip to content

Commit

Permalink
Show suggestion when locking metadata.lock fails
Browse files Browse the repository at this point in the history
  • Loading branch information
PGZXB committed Dec 18, 2022
1 parent 6467159 commit 3a3a5f9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
10 changes: 8 additions & 2 deletions taichi/cache/gfx/cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ CacheManager::CacheManager(Params &&init_params)
if (exists && lock_with_file(lock_path)) {
auto _ = make_cleanup([&lock_path]() {
if (!unlock_with_file(lock_path)) {
TI_WARN("Unlock {} failed", lock_path);
TI_WARN(
"Unlock {} failed. You can remove this .lock file manually and "
"try again.",
lock_path);
}
});
gfx::AotModuleParams params;
Expand Down Expand Up @@ -172,7 +175,10 @@ void CacheManager::dump_with_merging() const {
if (lock_with_file(lock_path)) {
auto _ = make_cleanup([&lock_path]() {
if (!unlock_with_file(lock_path)) {
TI_WARN("Unlock {} failed", lock_path);
TI_WARN(
"Unlock {} failed. You can remove this .lock file manually and "
"try again.",
lock_path);
}
});

Expand Down
19 changes: 15 additions & 4 deletions taichi/runtime/llvm/llvm_offline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,17 @@ bool LlvmOfflineCacheFileReader::load_meta_data(
if (lock_with_file(lock_path)) {
auto _ = make_cleanup([&lock_path]() {
if (!unlock_with_file(lock_path)) {
TI_WARN("Unlock {} failed", lock_path);
TI_WARN(
"Unlock {} failed. You can remove this .lock file manually and try "
"again.",
lock_path);
}
});
return Error::kNoError == load_metadata_with_checking(data, tcb_path);
}
TI_WARN("Lock {} failed", lock_path);
TI_WARN(
"Lock {} failed. You can remove this .lock file manually and try again.",
lock_path);
return false;
}

Expand Down Expand Up @@ -313,12 +318,18 @@ void LlvmOfflineCacheFileWriter::dump(const std::string &path,
// metadata file format to reduce overhead.
std::string lock_path = taichi::join_path(path, kMetadataFileLockName);
if (!lock_with_file(lock_path)) {
TI_WARN("Lock {} failed", lock_path);
TI_WARN(
"Lock {} failed. You can remove this .lock file manually and try "
"again.",
lock_path);
return;
}
auto _ = make_cleanup([&lock_path]() {
if (!unlock_with_file(lock_path)) {
TI_WARN("Unlock {} failed", lock_path);
TI_WARN(
"Unlock {} failed. You can remove this .lock file manually and try "
"again.",
lock_path);
}
});

Expand Down
5 changes: 4 additions & 1 deletion taichi/util/lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ inline bool lock_with_file(const std::string &path,
inline RaiiCleanup make_unlocker(const std::string &path) {
return make_cleanup([&path]() {
if (!unlock_with_file(path)) {
TI_WARN("Unlock {} failed", path);
TI_WARN(
"Unlock {} failed. You can remove this .lock file manually and try "
"again.",
path);
}
});
}
Expand Down
10 changes: 8 additions & 2 deletions taichi/util/offline_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,19 @@ class CacheCleaner {
std::string lock_path =
taichi::join_path(path, config.metadata_lock_name);
if (!lock_with_file(lock_path)) {
TI_WARN("Lock {} failed", lock_path);
TI_WARN(
"Lock {} failed. You can remove this .lock file manually and try "
"again.",
lock_path);
return;
}
auto _ = make_cleanup([&lock_path]() {
TI_DEBUG("Stop cleaning cache");
if (!unlock_with_file(lock_path)) {
TI_WARN("Unlock {} failed", lock_path);
TI_WARN(
"Unlock {} failed. You can remove this .lock file manually and "
"try again.",
lock_path);
}
});
TI_DEBUG("Start cleaning cache");
Expand Down

0 comments on commit 3a3a5f9

Please sign in to comment.