Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core][bugfix] Fix the C++ GcsClient Del not respecting del_by_prefix #45604

Merged
merged 2 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ray/gcs/gcs_client/accessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ Status InternalKVAccessor::AsyncInternalKVDel(const std::string &ns,
rpc::InternalKVDelRequest req;
req.set_namespace_(ns);
req.set_key(key);
req.set_del_by_prefix(del_by_prefix);
client_impl_->GetGcsRpcClient().InternalKVDel(
req,
[callback](const Status &status, const rpc::InternalKVDelReply &reply) {
Expand Down
37 changes: 37 additions & 0 deletions src/ray/gcs/gcs_client/test/gcs_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,43 @@ TEST_P(GcsClientTest, TestRegisterHeadNode) {
}
}

TEST_P(GcsClientTest, TestInternalKVDelByPrefix) {
// Test Del can del by prefix
bool added;
RAY_CHECK_OK(gcs_client_->InternalKV().Put("test_ns",
"test_key1",
"test_value1",
/*overwrite=*/false,
/*timeout_ms=*/-1,
added));
ASSERT_TRUE(added);
RAY_CHECK_OK(gcs_client_->InternalKV().Put("test_ns",
"test_key2",
"test_value2",
/*overwrite=*/false,
/*timeout_ms=*/-1,
added));
ASSERT_TRUE(added);
RAY_CHECK_OK(gcs_client_->InternalKV().Put("test_ns",
"other_key",
"test_value3",
/*overwrite=*/false,
/*timeout_ms=*/-1,
added));
ASSERT_TRUE(added);

int num_deleted;
RAY_CHECK_OK(gcs_client_->InternalKV().Del(
"test_ns", "test_key", /*del_by_prefix=*/true, /*timeout_ms=*/-1, num_deleted));
ASSERT_EQ(num_deleted, 2);

// ... and the other key should still be there
std::string value;
RAY_CHECK_OK(
gcs_client_->InternalKV().Get("test_ns", "other_key", /*timeout_ms=*/-1, value));
ASSERT_EQ(value, "test_value3");
}

// TODO(sang): Add tests after adding asyncAdd

} // namespace ray
Expand Down
Loading