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

Commit

Permalink
fix: fix meta response state to client during configuration query (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
foreverneverer authored and acelyc111 committed Dec 30, 2019
1 parent 0791461 commit 1e47429
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
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);
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

0 comments on commit 1e47429

Please sign in to comment.