Skip to content

Commit caac463

Browse files
committed
MB-47318: [BP] Add DcpControl to consumer and allow flow control override
Allow the client of the consumer to override the flow control buffer size which can be used by tests to give greater control over the flow-control logic. The use of DcpControl against a consumer is only permitted when the bucket is configured to allow it - and by default this is disabled. The intention is that tests will manually enable this with the correct bucket config. Change-Id: I5c4da722cb2660112e3b651c0e414dd79fc9524e Reviewed-on: https://review.couchbase.org/c/kv_engine/+/165015 Well-Formed: Restriction Checker Tested-by: Build Bot <[email protected]> Reviewed-by: James H <[email protected]>
1 parent 75d6f95 commit caac463

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

engines/ep/configuration.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@
310310
"dynamic": false,
311311
"type": "std::string"
312312
},
313+
"dcp_consumer_control_enabled" : {
314+
"default": "false",
315+
"descr": "When true, a DcpConsumer can accept control messages. This is intended to be used by tests.",
316+
"dynamic": false,
317+
"type": "bool"
318+
},
313319
"dcp_noop_mandatory_for_v5_features": {
314320
"default": "true",
315321
"descr": "Forces clients to enable noop for v5 features",

engines/ep/src/dcp/consumer.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "bucket_logger.h"
2121
#include "checkpoint_manager.h"
22+
#include "common.h"
2223
#include "dcp/dcpconnmap.h"
2324
#include "dcp/passive_stream.h"
2425
#include "dcp/response.h"
@@ -1893,3 +1894,24 @@ std::shared_ptr<PassiveStream> DcpConsumer::removeStream(Vbid vbid) {
18931894
engine_.getDcpConnMap().removeVBConnByVBId(getCookie(), vbid);
18941895
return eraseResult;
18951896
}
1897+
1898+
ENGINE_ERROR_CODE DcpConsumer::control(uint32_t opaque,
1899+
cb::const_char_buffer key,
1900+
cb::const_char_buffer value) {
1901+
if (engine_.getConfiguration().isDcpConsumerControlEnabled()) {
1902+
if (key == "connection_buffer_size") {
1903+
uint32_t result{0};
1904+
std::string valueStr(value.data(), value.size());
1905+
if (parseUint32(valueStr.c_str(), &result)) {
1906+
logger->warn("changing flow control buffer size:{}", result);
1907+
setFlowControlBufSize(result);
1908+
return ENGINE_SUCCESS;
1909+
}
1910+
}
1911+
1912+
logger->warn("Invalid ctrl parameter {} {}", key, value);
1913+
return ENGINE_EINVAL;
1914+
}
1915+
1916+
return ConnHandler::control(opaque, key, value);
1917+
}

engines/ep/src/dcp/consumer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ class DcpConsumer : public ConnHandler,
247247
uint64_t prepareSeqno,
248248
uint64_t abortSeqno) override;
249249

250+
ENGINE_ERROR_CODE control(uint32_t opaque,
251+
cb::const_char_buffer key,
252+
cb::const_char_buffer value) override;
253+
250254
bool doRollback(uint32_t opaque, Vbid vbid, uint64_t rollbackSeqno);
251255

252256
/**

engines/ep/tests/ep_testsuite.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7007,6 +7007,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
70077007
"ep_dcp_noop_mandatory_for_v5_features",
70087008
"ep_dcp_noop_tx_interval",
70097009
"ep_dcp_producer_snapshot_marker_yield_limit",
7010+
"ep_dcp_consumer_control_enabled",
70107011
"ep_dcp_consumer_process_buffered_messages_yield_limit",
70117012
"ep_dcp_consumer_process_buffered_messages_batch_size",
70127013
"ep_dcp_scan_byte_limit",
@@ -7205,6 +7206,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
72057206
"ep_dcp_conn_buffer_size_aggressive_perc",
72067207
"ep_dcp_conn_buffer_size_max",
72077208
"ep_dcp_conn_buffer_size_perc",
7209+
"ep_dcp_consumer_control_enabled",
72087210
"ep_dcp_consumer_process_buffered_messages_batch_size",
72097211
"ep_dcp_consumer_process_buffered_messages_yield_limit",
72107212
"ep_dcp_enable_noop",

0 commit comments

Comments
 (0)