Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

fix: fix meta response state to client during configuration query #354

Merged
merged 5 commits into from
Dec 12, 2019
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
14 changes: 12 additions & 2 deletions src/dist/replication/meta_server/server_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,18 @@ void server_state::query_configuration_by_index(
enum_to_string(app->status),
(app->app_name).c_str(),
app->app_id);
response.err =
(app->status == app_status::AS_CREATING ? ERR_BUSY_CREATING : ERR_BUSY_DROPPING);

switch (app->status) {
case app_status::AS_CREATING:
case app_status::AS_RECALLING:
response.err = ERR_BUSY_CREATING;
break;
case app_status::AS_DROPPING:
response.err = ERR_BUSY_DROPPING;
break;
default:
response.err = ERR_UNKNOWN;
}
return;
}

Expand Down
24 changes: 24 additions & 0 deletions src/dist/replication/test/meta_test/unit_test/state_sync_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,30 @@ void meta_service_test_app::state_sync_test()
req.app_name = "make_no_sense";
ss2->query_configuration_by_index(req, resp);
ASSERT_EQ(dsn::ERR_OBJECT_NOT_FOUND, resp.err);

// 3.3 app is dropping/creating/recalling
std::shared_ptr<app_state> app = ss2->get_app(15);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我感觉这里用了好多15数字常量不太好,能不能统一到一个变量里?要不然把15改的话需要改一大片

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不相干的重构可以后续统一改

req.app_name = app->app_name;

ss2->query_configuration_by_index(req, resp);
ASSERT_EQ(dsn::ERR_OK, resp.err);

app->status = dsn::app_status::AS_DROPPING;
ss2->query_configuration_by_index(req, resp);
ASSERT_EQ(dsn::ERR_BUSY_DROPPING, resp.err);

app->status = dsn::app_status::AS_RECALLING;
ss2->query_configuration_by_index(req, resp);
ASSERT_EQ(dsn::ERR_BUSY_CREATING, resp.err);

app->status = dsn::app_status::AS_CREATING;
ss2->query_configuration_by_index(req, resp);
ASSERT_EQ(dsn::ERR_BUSY_CREATING, resp.err);

// client unknown state
app->status = dsn::app_status::AS_DROP_FAILED;
ss2->query_configuration_by_index(req, resp);
ASSERT_EQ(dsn::ERR_UNKNOWN, resp.err);
}

// simulate the half creating
Expand Down