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

Fix gcs_table_storage testcase bug #9393

Merged
Merged
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
17 changes: 12 additions & 5 deletions src/ray/gcs/gcs_server/test/gcs_table_storage_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,25 @@ class GcsTableStorageTestBase : public ::testing::Test {

template <typename TABLE, typename KEY, typename VALUE>
void Put(TABLE &table, const KEY &key, const VALUE &value) {
auto on_done = [this](Status status) { --pending_count_; };
auto on_done = [this](const Status &status) { --pending_count_; };
++pending_count_;
RAY_CHECK_OK(table.Put(key, value, on_done));
WaitPendingDone();
}

template <typename TABLE, typename KEY, typename VALUE>
int Get(TABLE &table, const KEY &key, std::vector<VALUE> &values) {
auto on_done = [this, &values](Status status, const boost::optional<VALUE> &result) {
auto on_done = [this, &values](const Status &status,
const boost::optional<VALUE> &result) {
RAY_CHECK_OK(status);
--pending_count_;
values.clear();
if (result) {
values.push_back(*result);
}
// NOTE: The callback is executed in an asynchronous thread, so the modification of
// pending_count_ must be put last, otherwise the unmodified pending_count_ will be
// read outside.
--pending_count_;
};
++pending_count_;
RAY_CHECK_OK(table.Get(key, on_done));
Expand All @@ -105,13 +109,16 @@ class GcsTableStorageTestBase : public ::testing::Test {
int GetByJobId(TABLE &table, const JobID &job_id, const KEY &key,
std::vector<VALUE> &values) {
auto on_done = [this, &values](const std::unordered_map<KEY, VALUE> &result) {
--pending_count_;
values.clear();
if (!result.empty()) {
for (auto &item : result) {
values.push_back(item.second);
}
}
// NOTE: The callback is executed in an asynchronous thread, so the modification of
// pending_count_ must be put last, otherwise the unmodified pending_count_ will be
// read outside.
--pending_count_;
};
++pending_count_;
RAY_CHECK_OK(table.GetByJobId(job_id, on_done));
Expand All @@ -121,7 +128,7 @@ class GcsTableStorageTestBase : public ::testing::Test {

template <typename TABLE, typename KEY>
void Delete(TABLE &table, const KEY &key) {
auto on_done = [this](Status status) {
auto on_done = [this](const Status &status) {
RAY_CHECK_OK(status);
--pending_count_;
};
Expand Down