Skip to content

Commit 8d13b01

Browse files
committed
MB-43205: Introduce the allow_sanitize_value_in_deletion config param
This is a renaming of the previous allow_del_with_meta_prune_user_data config param. As per its old name, that was a switch for enabling/disabling del_with_meta operating in "sanitizer" mode rather than enforcing a strict validation and failing the operation in the case of invalid payload. Now we want to extend the same behaviour to DCP_DELETE/DCP_PREPARE. That is because in 6.6.0 we have introduced some stricter validation on deletion payloads that may fail the operation. That may happen mainly in the case of pre-6.6 to 6.6 offline upgrade. Under this MB we want to introduce the possibility to set a replica in "sanitizer" mode, the same as we already do at del_with_meta. That way, DCP_DELETE/DCP_PREPARE will just remove any invalid body in the payload rather that failing. Change-Id: Ia9faff48de3a51a77d367961b45c41ed45c609d1 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/143656 Well-Formed: Build Bot <[email protected]> Tested-by: Paolo Cocchi <[email protected]> Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 51684ab commit 8d13b01

File tree

7 files changed

+26
-19
lines changed

7 files changed

+26
-19
lines changed

engines/ep/configuration.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"params": {
3-
"allow_del_with_meta_prune_user_data" : {
3+
"allow_sanitize_value_in_deletion" : {
44
"default" : "true",
5-
"descr": "Let del_with_meta prune user data provided from the user instead of failing",
5+
"descr": "Let EPE delete/prepare/del_with_meta prune any invalid body in the payload instead of failing",
66
"dynamic" : true,
77
"type" : "bool"
88
},

engines/ep/src/ep_engine.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,8 @@ cb::mcbp::Status EventuallyPersistentEngine::setFlushParam(
744744
getConfiguration().setCouchstoreWriteValidation(cb_stob(val));
745745
} else if (key == "couchstore_mprotect") {
746746
getConfiguration().setCouchstoreMprotect(cb_stob(val));
747-
} else if (key == "allow_del_with_meta_prune_user_data") {
748-
getConfiguration().setAllowDelWithMetaPruneUserData(cb_stob(val));
747+
} else if (key == "allow_sanitize_value_in_deletion") {
748+
getConfiguration().setAllowSanitizeValueInDeletion(cb_stob(val));
749749
} else {
750750
msg = "Unknown config param";
751751
rv = cb::mcbp::Status::KeyEnoent;
@@ -2051,8 +2051,8 @@ class EpEngineValueChangeListener : public ValueChangedListener {
20512051
}
20522052

20532053
void booleanValueChanged(const std::string& key, bool b) override {
2054-
if (key == "allow_del_with_meta_prune_user_data") {
2055-
engine.allowDelWithMetaPruneUserData.store(b);
2054+
if (key == "allow_sanitize_value_in_deletion") {
2055+
engine.allowSanitizeValueInDeletion.store(b);
20562056
}
20572057
}
20582058

@@ -2139,10 +2139,10 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::initialize(const char* config) {
21392139
"getl_max_timeout",
21402140
std::make_unique<EpEngineValueChangeListener>(*this));
21412141

2142-
allowDelWithMetaPruneUserData.store(
2143-
configuration.isAllowDelWithMetaPruneUserData());
2142+
allowSanitizeValueInDeletion.store(
2143+
configuration.isAllowSanitizeValueInDeletion());
21442144
configuration.addValueChangedListener(
2145-
"allow_del_with_meta_prune_user_data",
2145+
"allow_sanitize_value_in_deletion",
21462146
std::make_unique<EpEngineValueChangeListener>(*this));
21472147

21482148
auto numShards = configuration.getMaxNumShards();
@@ -5554,7 +5554,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::deleteWithMeta(
55545554
datatype &= ~PROTOCOL_BINARY_DATATYPE_SNAPPY;
55555555
}
55565556

5557-
if (allowDelWithMetaPruneUserData) {
5557+
if (allowSanitizeValueInDeletion) {
55585558
if (mcbp::datatype::is_xattr(datatype)) {
55595559
// Whatever we have in the value, just keep Xattrs
55605560
const auto valBuffer = cb::const_char_buffer{

engines/ep/src/ep_engine.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,5 +1161,12 @@ class EventuallyPersistentEngine : public EngineIface, public DcpIface {
11611161
EpEngineTaskable taskable;
11621162
std::atomic<BucketCompressionMode> compressionMode;
11631163
std::atomic<float> minCompressionRatio;
1164-
std::atomic_bool allowDelWithMetaPruneUserData;
1164+
1165+
/**
1166+
* Whether del-operations at EPE level (currently only DelWithMeta) should
1167+
* just sanitize invalid payloads or fail the operation if an invalid
1168+
* payload is detected.
1169+
* Non-const as the related configuration param is dynamic.
1170+
*/
1171+
std::atomic_bool allowSanitizeValueInDeletion;
11651172
};

engines/ep/tests/ep_testsuite.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6961,7 +6961,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
69616961
{"info", {"info"}},
69626962
{"allocator", {"detailed"}},
69636963
{"config",
6964-
{"ep_allow_del_with_meta_prune_user_data",
6964+
{"ep_allow_sanitize_value_in_deletion",
69656965
"ep_backend",
69666966
"ep_backfill_mem_threshold",
69676967
"ep_bfilter_enabled",
@@ -7131,7 +7131,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
71317131
"vb_0:num_entries",
71327132
"vb_0:num_erroneous_entries_erased"}},
71337133
{"", // Note: we convert empty to a null to get engine stats
7134-
{"ep_allow_del_with_meta_prune_user_data",
7134+
{"ep_allow_sanitize_value_in_deletion",
71357135
"bytes",
71367136
"curr_items",
71377137
"curr_items_tot",

engines/ep/tests/mock/mock_synchronous_ep_engine.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ SynchronousEPEngine::SynchronousEPEngine(std::string extra_config)
7575
maxItemSize = configuration.getMaxItemSize();
7676

7777
setCompressionMode(configuration.getCompressionMode());
78-
allowDelWithMetaPruneUserData =
79-
configuration.isAllowDelWithMetaPruneUserData();
78+
allowSanitizeValueInDeletion =
79+
configuration.isAllowSanitizeValueInDeletion();
8080
}
8181

8282
void SynchronousEPEngine::setKVBucket(std::unique_ptr<KVBucket> store) {

engines/ep/tests/module_tests/evp_store_with_meta.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class WithMetaTest : public SingleThreadedEPBucketTest {
4242
if (!config_string.empty()) {
4343
config_string += ";";
4444
}
45-
config_string += "allow_del_with_meta_prune_user_data=true";
45+
config_string += "allow_sanitize_value_in_deletion=true";
4646
SingleThreadedEPBucketTest::SetUp();
4747
store->setVBucketState(vbid, vbucket_state_active);
4848
expiry = ep_real_time() + 31557600; // +1 year in seconds

tests/testapp/testapp_withmeta.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ TEST_P(WithMetaTest, MB36321_DeleteWithMetaRefuseUserXattrs) {
216216
conn.selectBucket(bucketName);
217217
const auto setParam = BinprotSetParamCommand(
218218
cb::mcbp::request::SetParamPayload::Type::Flush,
219-
"allow_del_with_meta_prune_user_data",
219+
"allow_sanitize_value_in_deletion",
220220
"false");
221221
const auto resp = BinprotMutationResponse(conn.execute(setParam));
222222
ASSERT_EQ(cb::mcbp::Status::Success, resp.getStatus());
@@ -292,7 +292,7 @@ void WithMetaTest::testDeleteWithMetaAcceptsUserXattrs(bool allowValuePruning,
292292
conn.selectBucket(bucketName);
293293
const auto setParam = BinprotSetParamCommand(
294294
cb::mcbp::request::SetParamPayload::Type::Flush,
295-
"allow_del_with_meta_prune_user_data",
295+
"allow_sanitize_value_in_deletion",
296296
allowValuePruning ? "true" : "false");
297297
const auto resp = BinprotMutationResponse(conn.execute(setParam));
298298
ASSERT_EQ(cb::mcbp::Status::Success, resp.getStatus());
@@ -356,7 +356,7 @@ void WithMetaTest::testDeleteWithMetaRejectsBody(bool allowValuePruning,
356356
conn.selectBucket(bucketName);
357357
const auto setParam = BinprotSetParamCommand(
358358
cb::mcbp::request::SetParamPayload::Type::Flush,
359-
"allow_del_with_meta_prune_user_data",
359+
"allow_sanitize_value_in_deletion",
360360
allowValuePruning ? "true" : "false");
361361
const auto resp = BinprotMutationResponse(conn.execute(setParam));
362362
ASSERT_EQ(cb::mcbp::Status::Success, resp.getStatus());

0 commit comments

Comments
 (0)