Skip to content

Commit 92824c7

Browse files
rohansurimohammadzaeem
authored andcommitted
MB-65655 Refactor Fusion mcbp to now only delete a single namespace
The API for deleting namespaces has changed. From previously providing an except list, now Magma only supports deleting the given namespace. Linked Magma change: https://review.couchbase.org/c/magma/+/226743 Change-Id: I84b534c9a99ad283e35aec1dee294d6917d31695 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/226845 Reviewed-by: Trond Norbye <trond.norbye@couchbase.com> Reviewed-by: Mohammad Zaeem <mohammad.zaeem@couchbase.com> Tested-by: Build Bot <build@couchbase.com>
1 parent 4ad0b66 commit 92824c7

File tree

12 files changed

+52
-85
lines changed

12 files changed

+52
-85
lines changed

daemon/mcbp_executors.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "protocol/mcbp/dcp_expiration.h"
2626
#include "protocol/mcbp/dcp_mutation.h"
2727
#include "protocol/mcbp/dcp_system_event_executor.h"
28-
#include "protocol/mcbp/delete_fusion_namespaces_command_context.h"
28+
#include "protocol/mcbp/delete_fusion_namespace_command_context.h"
2929
#include "protocol/mcbp/engine_wrapper.h"
3030
#include "protocol/mcbp/executors.h"
3131
#include "protocol/mcbp/gat_context.h"
@@ -693,8 +693,8 @@ static void set_chronicle_auth_token_executor(Cookie& cookie) {
693693
cookie.obtainContext<SetChronicleAuthTokenCommandContext>(cookie).drive();
694694
}
695695

696-
static void delete_fusion_namespaces_executor(Cookie& cookie) {
697-
cookie.obtainContext<DeleteFusionNamespacesCommandContext>(cookie).drive();
696+
static void delete_fusion_namespace_executor(Cookie& cookie) {
697+
cookie.obtainContext<DeleteFusionNamespaceCommandContext>(cookie).drive();
698698
}
699699

700700
static void process_bin_noop_response(Cookie&) {
@@ -982,8 +982,8 @@ void initialize_mbcp_lookup_map() {
982982
stop_fusion_uploader_executor);
983983
setup_handler(cb::mcbp::ClientOpcode::SetChronicleAuthToken,
984984
set_chronicle_auth_token_executor);
985-
setup_handler(cb::mcbp::ClientOpcode::DeleteFusionNamespaces,
986-
delete_fusion_namespaces_executor);
985+
setup_handler(cb::mcbp::ClientOpcode::DeleteFusionNamespace,
986+
delete_fusion_namespace_executor);
987987

988988
setup_handler(cb::mcbp::ClientOpcode::StartPersistence,
989989
start_persistence_executor);

daemon/mcbp_privileges.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ McbpPrivilegeChains::McbpPrivilegeChains() {
290290
setup(ClientOpcode::StopFusionUploader, require<Privilege::NodeSupervisor>);
291291
setup(ClientOpcode::SetChronicleAuthToken,
292292
require<Privilege::NodeSupervisor>);
293-
setup(ClientOpcode::DeleteFusionNamespaces,
293+
setup(ClientOpcode::DeleteFusionNamespace,
294294
require<Privilege::NodeSupervisor>);
295295

296296
if (getenv("MEMCACHED_UNIT_TESTS") != nullptr) {

daemon/mcbp_validators.cc

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,7 @@ static Status set_chronicle_auth_token_validator(Cookie& cookie) {
29022902
return status;
29032903
}
29042904

2905-
Status delete_fusion_namespaces_validator(Cookie& cookie) {
2905+
Status delete_fusion_namespace_validator(Cookie& cookie) {
29062906
auto status = McbpValidator::verify_header(cookie,
29072907
0,
29082908
ExpectedKeyLen::Zero,
@@ -2921,67 +2921,57 @@ Status delete_fusion_namespaces_validator(Cookie& cookie) {
29212921
} catch (const nlohmann::json::exception& e) {
29222922
// Note: Don't log the full payload
29232923
const auto msg = fmt::format(
2924-
"delete_fusion_namespaces_validator: Invalid json format {}",
2924+
"delete_fusion_namespace_validator: Invalid json format {}",
29252925
e.what());
29262926
cookie.setErrorContext(msg);
29272927
return Status::Einval;
29282928
}
29292929

29302930
if (!json.contains("logstore_uri")) {
29312931
cookie.setErrorContext(
2932-
"delete_fusion_namespaces_validator: Missing logstore_uri");
2932+
"delete_fusion_namespace_validator: Missing logstore_uri");
29332933
return Status::Einval;
29342934
}
29352935
if (!json["logstore_uri"].is_string()) {
29362936
cookie.setErrorContext(
2937-
"delete_fusion_namespaces_validator: logstore_uri not string");
2937+
"delete_fusion_namespace_validator: logstore_uri not string");
29382938
return Status::Einval;
29392939
}
29402940

29412941
if (!json.contains("metadatastore_uri")) {
29422942
cookie.setErrorContext(
2943-
"delete_fusion_namespaces_validator: Missing "
2943+
"delete_fusion_namespace_validator: Missing "
29442944
"metadatastore_uri");
29452945
return Status::Einval;
29462946
}
29472947
if (!json["metadatastore_uri"].is_string()) {
29482948
cookie.setErrorContext(
2949-
"delete_fusion_namespaces_validator: metadatastore_uri not "
2949+
"delete_fusion_namespace_validator: metadatastore_uri not "
29502950
"string");
29512951
return Status::Einval;
29522952
}
29532953

29542954
if (!json.contains("metadatastore_auth_token")) {
29552955
cookie.setErrorContext(
2956-
"delete_fusion_namespaces_validator: Missing "
2956+
"delete_fusion_namespace_validator: Missing "
29572957
"metadatastore_auth_token");
29582958
return Status::Einval;
29592959
}
29602960
if (!json["metadatastore_auth_token"].is_string()) {
29612961
cookie.setErrorContext(
2962-
"delete_fusion_namespaces_validator: metadatastore_auth_token "
2962+
"delete_fusion_namespace_validator: metadatastore_auth_token "
29632963
"not string");
29642964
return Status::Einval;
29652965
}
29662966

2967-
if (!json.contains("namespaces")) {
2967+
if (!json.contains("namespace")) {
29682968
cookie.setErrorContext(
2969-
"delete_fusion_namespaces_validator: Missing mountPaths");
2969+
"delete_fusion_namespace_validator: Missing namespace");
29702970
return Status::Einval;
29712971
}
2972-
if (!json["namespaces"].is_array()) {
2972+
if (!json["namespace"].is_string()) {
29732973
cookie.setErrorContext(
2974-
"delete_fusion_namespaces_validator: namespaces not an array");
2975-
return Status::Einval;
2976-
}
2977-
try {
2978-
std::vector<std::string> paths = json["namespaces"];
2979-
} catch (const std::exception& e) {
2980-
const auto msg = fmt::format(
2981-
"delete_fusion_namespaces_validator: Invalid json '{}' {}",
2982-
value,
2983-
e.what());
2984-
cookie.setErrorContext(msg);
2974+
"delete_fusion_namespace_validator: namespace not string");
29852975
return Status::Einval;
29862976
}
29872977

@@ -3299,6 +3289,6 @@ McbpValidator::McbpValidator() {
32993289
stop_fusion_uploader_validator);
33003290
setup(cb::mcbp::ClientOpcode::SetChronicleAuthToken,
33013291
set_chronicle_auth_token_validator);
3302-
setup(cb::mcbp::ClientOpcode::DeleteFusionNamespaces,
3303-
delete_fusion_namespaces_validator);
3292+
setup(cb::mcbp::ClientOpcode::DeleteFusionNamespace,
3293+
delete_fusion_namespace_validator);
33043294
}

daemon/protocol/mcbp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ add_library(memcached_daemon_mcbp OBJECT
4040
dcp_stream_req_executor.cc
4141
dcp_system_event_executor.cc
4242
dcp_system_event_executor.h
43-
delete_fusion_namespaces_command_context.cc
44-
delete_fusion_namespaces_command_context.h
43+
delete_fusion_namespace_command_context.cc
44+
delete_fusion_namespace_command_context.h
4545
drop_privilege_executor.cc
4646
engine_wrapper.cc
4747
engine_wrapper.h

daemon/protocol/mcbp/delete_fusion_namespaces_command_context.cc renamed to daemon/protocol/mcbp/delete_fusion_namespace_command_context.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* the file licenses/APL2.txt.
99
*/
1010

11-
#include "delete_fusion_namespaces_command_context.h"
11+
#include "delete_fusion_namespace_command_context.h"
1212

1313
#include <daemon/concurrency_semaphores.h>
1414
#include <daemon/cookie.h>
@@ -18,31 +18,31 @@
1818
#endif
1919
#include <logger/logger.h>
2020

21-
DeleteFusionNamespacesCommandContext::DeleteFusionNamespacesCommandContext(
21+
DeleteFusionNamespaceCommandContext::DeleteFusionNamespaceCommandContext(
2222
Cookie& cookie)
2323
: BackgroundThreadCommandContext(
2424
cookie,
25-
TaskId::Core_DeleteFusionNamespacesTask,
26-
fmt::format("Core_DeleteFusionNamespacesTask:{}",
25+
TaskId::Core_DeleteFusionNamespaceTask,
26+
fmt::format("Core_DeleteFusionNamespaceTask:{}",
2727
cookie.getRequest().getVBucket()),
2828
ConcurrencySemaphores::instance().fusion_management) {
2929
}
3030

31-
cb::engine_errc DeleteFusionNamespacesCommandContext::execute() {
31+
cb::engine_errc DeleteFusionNamespaceCommandContext::execute() {
3232
#ifdef USE_FUSION
3333
const auto& req = cookie.getRequest();
3434
const auto request = nlohmann::json::parse(req.getValueString());
3535
const auto logstore = request["logstore_uri"];
3636
const auto metadatastore = request["metadatastore_uri"];
3737
const auto token = request["metadatastore_auth_token"];
38-
const auto namespaces = request["namespaces"];
39-
const auto status = magma::Magma::DeleteFusionNamespacesExcept(
40-
logstore, metadatastore, token, namespaces);
38+
const auto ns = request["namespace"];
39+
const auto status = magma::Magma::DeleteFusionNamespace(
40+
logstore, metadatastore, token, ns);
4141
if (status.ErrorCode() != magma::Status::Code::Ok) {
42-
LOG_WARNING_CTX("DeleteFusionNamespacesExcept: ",
42+
LOG_WARNING_CTX("DeleteFusionNamespace: ",
4343
{"logstore_uri", logstore},
4444
{"metadatastore_uri", metadatastore},
45-
{"namespaces", namespaces},
45+
{"namespace", ns},
4646
{"error", status.String()});
4747
return cb::engine_errc::failed;
4848
}

daemon/protocol/mcbp/delete_fusion_namespaces_command_context.h renamed to daemon/protocol/mcbp/delete_fusion_namespace_command_context.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#include "background_thread_command_context.h"
1313

1414
/**
15-
* Command context for executing DeleteFusionNamespaces requests in a
15+
* Command context for executing DeleteFusionNamespace requests in a
1616
* AUXIO bg-thread and avoiding blocking IO in frontend threads.
1717
*/
18-
class DeleteFusionNamespacesCommandContext
18+
class DeleteFusionNamespaceCommandContext
1919
: public BackgroundThreadCommandContext {
2020
public:
21-
explicit DeleteFusionNamespacesCommandContext(Cookie& cookie);
21+
explicit DeleteFusionNamespaceCommandContext(Cookie& cookie);
2222

2323
protected:
2424
cb::engine_errc execute() override;

docs/fusion.md

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ will contain details.
301301
This status code is used for unexpected internal failure.
302302

303303

304-
# 0x77 - Delete Fusion Namespaces
304+
# 0x77 - Delete Fusion Namespace
305305

306306
The command deletes data from the given FusionLogStore and FusionMetadataStore
307-
for all Fusion volumes except those that are specified as a parameter to the call.
307+
for all Fusion volumes under the given namespace.
308308

309309
The request has:
310310
* No extras
@@ -331,9 +331,9 @@ Any key not shown in the following sections will be ignored.
331331
* `"metadatastore_auth_token"`
332332
* The value is a string
333333

334-
* The Fusion namespaces that must be excluded in the deletion
335-
* `"namespaces"`
336-
* The value is an array of strings
334+
* The Fusion namespace under which data for all volumes is to be deleted
335+
* `"namespace"`
336+
* The value is a string
337337

338338
### Examples
339339

@@ -342,16 +342,7 @@ Any key not shown in the following sections will be ignored.
342342
"logstore_uri": "uri1",
343343
"metadatastore_uri": "uri2"
344344
"metadatastore_auth_token": "some-token"
345-
"namespaces": ["namespace-to-preserve", "another-one"]
346-
}
347-
```
348-
349-
```
350-
{
351-
"logstore_uri": "uri1",
352-
"metadatastore_uri": "uri2"
353-
"metadatastore_auth_token": "some-token"
354-
"namespaces": []
345+
"namespaces": "namespace-to-delete"
355346
}
356347
```
357348

executor/tasks.def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ TASK(Core_ReleaseFusionStorageSnapshotTask, TaskType::AuxIO, 6)
8080
TASK(Core_StartFusionUploaderTask, TaskType::AuxIO, 6)
8181
TASK(Core_StopFusionUploaderTask, TaskType::AuxIO, 6)
8282
TASK(Core_SetChronicleAuthTokenTask, TaskType::AuxIO, 6)
83-
TASK(Core_DeleteFusionNamespacesTask, TaskType::AuxIO, 6)
83+
TASK(Core_DeleteFusionNamespaceTask, TaskType::AuxIO, 6)
8484

8585
// Read/Write IO tasks
8686
TASK(RollbackTask, TaskType::Writer, 1)

include/mcbp/protocol/opcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ enum class ClientOpcode : uint8_t {
159159
SyncFusionLogstore = 0x74,
160160
StartFusionUploader = 0x75,
161161
StopFusionUploader = 0x76,
162-
DeleteFusionNamespaces = 0x77,
162+
DeleteFusionNamespace = 0x77,
163163
ReservedFusion8 = 0x78,
164164

165165
StopPersistence = 0x80,

protocol/mcbp/opcode.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ class OpcodeInformationService {
829829
{"STOP_FUSION_UPLOADER"sv, {Attribute::Supported}});
830830
setup(ClientOpcode::SetChronicleAuthToken,
831831
{"SET_CHRONICLE_AUTH_TOKEN"sv, {Attribute::Supported}});
832-
setup(ClientOpcode::DeleteFusionNamespaces,
833-
{"DELETE_FUSION_NAMESPACES"sv, {Attribute::Supported}});
832+
setup(ClientOpcode::DeleteFusionNamespace,
833+
{"DELETE_FUSION_NAMESPACE"sv, {Attribute::Supported}});
834834
}
835835

836836
protected:

0 commit comments

Comments
 (0)