return g
@cmd
-def set_param(mc, type, key, val):
+def set_param(mc, type, key, val, vbucket):
engine_param = None
if type == 'checkpoint_param':
engine_param = memcacheConstants.ENGINE_PARAM_CHECKPOINT
val = str(int(float(_x_)*(_quota_)/100))
try:
- mc.set_param(key, val, engine_param)
+ mc.set_param(int(vbucket), key, val, engine_param)
print 'set %s to %s' %(key, val)
except mc_bin_client.MemcachedError, error:
print 'Error: %s' % error.msg
dcp_consumer_process_buffered_messages_batch_size - The number of items the
DCP processor will consume
in a single batch.
+ Available params for "set vbucket_param":
+ max_cas - Change the max_cas of a vbucket. The value and vbucket are specified as decimal
+ integers. The new-value is interpretted as an unsigned 64-bit integer.
+
+ cbepctl host:port -b default set vbucket_param max_cas <new-value> <vbucket-id>
""")
c.addCommand('drain', drain, "drain")
- c.addCommand('set', set_param, 'set type param value')
+ c.addCommand('set', set_param, 'set type param value vbucket')
c.addCommand('start', start, 'start')
c.addCommand('stop', stop, 'stop')
c.addFlag('-a', 'allBuckets', 'iterate over all buckets (requires admin u/p)')
def start_persistence(self):
return self._doCmd(memcacheConstants.CMD_START_PERSISTENCE, '', '')
- def set_param(self, key, val, type):
+ def set_param(self, vbucket, key, val, type):
print "setting param:", key, val
+ self.vbucketId = vbucket
type = struct.pack(memcacheConstants.SET_PARAM_FMT, type)
return self._doCmd(memcacheConstants.CMD_SET_PARAM, key, val, type)
((double)(config.getCursorDroppingUpperMark()) / 100)));
}
+ENGINE_ERROR_CODE EventuallyPersistentStore::forceMaxCas(uint16_t vbucket,
+ uint64_t cas) {
+ RCPtr<VBucket> vb = vbMap.getBucket(vbucket);
+ if (vb) {
+ vb->forceMaxCas(cas);
+ return ENGINE_SUCCESS;
+ }
+ return ENGINE_NOT_MY_VBUCKET;
+}
+
std::ostream& operator<<(std::ostream& os,
const EventuallyPersistentStore::Position& pos) {
os << "vbucket:" << pos.vbucket_id;
//Check if there were any out-of-memory errors during warmup
bool isWarmupOOMFailure(void);
+ /*
+ * Change the max_cas of the specified vbucket to cas without any
+ * care for the data or ongoing operations...
+ */
+ ENGINE_ERROR_CODE forceMaxCas(uint16_t vbucket, uint64_t cas);
+
protected:
// During the warmup phase we might want to enable external traffic
// at a given point in time.. The LoadStorageKvPairCallback will be
static protocol_binary_response_status setVbucketParam(
EventuallyPersistentEngine *e,
+ uint16_t vbucket,
const char *keyz,
const char *valz,
std::string& msg) {
uint64_t v = std::strtoull(valz, nullptr, 10);
checkNumeric(valz);
e->getConfiguration().setHlcBehindThresholdUs(v);
+ } else if (strcmp(keyz, "max_cas") == 0) {
+ uint64_t v = std::strtoull(valz, nullptr, 10);
+ checkNumeric(valz);
+ LOG(EXTENSION_LOG_WARNING, "setVbucketParam max_cas=%" PRIu64 " "
+ "vbucket=%" PRIu16 "\n", v, vbucket);
+ if (e->getEpStore()->forceMaxCas(vbucket, v) != ENGINE_SUCCESS) {
+ rv = PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET;
+ msg = "Not my vbucket";
+ }
} else {
msg = "Unknown config param";
rv = PROTOCOL_BINARY_RESPONSE_KEY_ENOENT;
size_t keylen = ntohs(req->message.header.request.keylen);
uint8_t extlen = req->message.header.request.extlen;
size_t vallen = ntohl(req->message.header.request.bodylen);
+ uint16_t vbucket = ntohs(req->message.header.request.vbucket);
protocol_binary_engine_param_t paramtype =
static_cast<protocol_binary_engine_param_t>(ntohl(req->message.body.param_type));
rv = setDcpParam(e, keyz, valz, msg);
break;
case protocol_binary_engine_param_vbucket:
- rv = setVbucketParam(e, keyz, valz, msg);
+ rv = setVbucketParam(e, vbucket, keyz, valz, msg);
break;
default:
rv = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
atomic_setIfBigger(maxHLC, hlc);
}
+ void forceMaxHLC(uint64_t hlc) {
+ maxHLC = hlc;
+ }
+
uint64_t getMaxHLC() const {
return maxHLC;
}
hlc.setMaxHLCAndTrackDrift(cas);
}
+ void forceMaxCas(uint64_t cas) {
+ hlc.forceMaxHLC(cas);
+ }
+
HLC::DriftStats getHLCDriftStats() const {
return hlc.getDriftStats();
}
}
bool set_param(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1, protocol_binary_engine_param_t paramtype,
- const char *param, const char *val) {
+ const char *param, const char *val, uint16_t vb) {
char ext[4];
protocol_binary_request_header *pkt;
encodeExt(ext, static_cast<uint32_t>(paramtype));
- pkt = createPacket(PROTOCOL_BINARY_CMD_SET_PARAM, 0, 0, ext, sizeof(protocol_binary_engine_param_t), param,
+ pkt = createPacket(PROTOCOL_BINARY_CMD_SET_PARAM, vb, 0, ext, sizeof(protocol_binary_engine_param_t), param,
strlen(param), val, strlen(val));
if (h1->unknown_command(h, NULL, pkt, add_response) != ENGINE_SUCCESS) {
vbucket_state_t state, bool makeinvalidkey = false) CB_MUST_USE_RESULT;
bool set_param(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1, protocol_binary_engine_param_t paramtype,
- const char *param, const char *val);
+ const char *param, const char *val, uint16_t vb = 0);
bool set_vbucket_state(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1,
uint16_t vb, vbucket_state_t state);
bool get_all_vb_seqnos(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1,
return SUCCESS;
}
+static enum test_result set_max_cas_mb21190(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
+ uint64_t max_cas = get_ull_stat(h, h1, "vb_0:max_cas", "vbucket-details 0");
+ std::string max_cas_str = std::to_string(max_cas+1);
+ set_param(h, h1, protocol_binary_engine_param_vbucket,
+ "max_cas", max_cas_str.data(), 0);
+ checkeq(PROTOCOL_BINARY_RESPONSE_SUCCESS, last_status.load(),
+ "Failed to set_param max_cas");
+ checkeq(max_cas + 1,
+ get_ull_stat(h, h1, "vb_0:max_cas", "vbucket-details 0"),
+ "max_cas didn't change");
+ set_param(h, h1, protocol_binary_engine_param_vbucket,
+ "max_cas", max_cas_str.data(), 1);
+ checkeq(PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET, last_status.load(),
+ "Expected not my vbucket for vb 1");
+ set_param(h, h1, protocol_binary_engine_param_vbucket,
+ "max_cas", "JUNK", 0);
+ checkeq(PROTOCOL_BINARY_RESPONSE_EINVAL, last_status.load(),
+ "Expected EINVAL");
+ return SUCCESS;
+}
+
///////////////////////////////////////////////////////////////////////////////
// Test manifest //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
TestCase("flushall params", test_CBD_152, test_setup, teardown,
"flushall_enabled=true;max_vbuckets=16;"
"ht_size=7;ht_locks=3", prepare, cleanup),
+ TestCase("set max_cas MB21190", set_max_cas_mb21190, test_setup, teardown, nullptr,
+ prepare, cleanup),
// sentinel
TestCase(NULL, NULL, NULL, NULL, NULL, prepare, cleanup)