diff --git a/src/dist/replication/meta_server/server_state.cpp b/src/dist/replication/meta_server/server_state.cpp index af9478e629..27436b9244 100644 --- a/src/dist/replication/meta_server/server_state.cpp +++ b/src/dist/replication/meta_server/server_state.cpp @@ -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; } diff --git a/src/dist/replication/test/meta_test/unit_test/state_sync_test.cpp b/src/dist/replication/test/meta_test/unit_test/state_sync_test.cpp index f5cab10023..6e4952506a 100644 --- a/src/dist/replication/test/meta_test/unit_test/state_sync_test.cpp +++ b/src/dist/replication/test/meta_test/unit_test/state_sync_test.cpp @@ -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 = 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