Skip to content

Commit

Permalink
Merge remote-tracking branch 'couchbase/watson' into master
Browse files Browse the repository at this point in the history
* couchbase/watson:
  MB-20425: Change options parameter to correct values
  MB-20425: Remove default options parameter from get functions

Change-Id: If98ef0e46d34e39c98b096098d8130e2a363bd4d
  • Loading branch information
daverigby committed Aug 8, 2016
2 parents 10f938d + 1d9bd1e commit 3fc5e69
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
8 changes: 1 addition & 7 deletions src/ep.h
Expand Up @@ -256,13 +256,7 @@ class EventuallyPersistentStore {
* @return a GetValue representing the result of the request
*/
GetValue get(const std::string &key, uint16_t vbucket,
const void *cookie,
get_options_t options = static_cast<get_options_t>(
QUEUE_BG_FETCH |
HONOR_STATES |
TRACK_REFERENCE |
DELETE_TEMP |
HIDE_LOCKED_CAS)) {
const void *cookie, get_options_t options) {
return getInternal(key, vbucket, cookie, vbucket_state_active,
options);
}
Expand Down
17 changes: 15 additions & 2 deletions src/ep_engine.cc
Expand Up @@ -206,9 +206,16 @@ extern "C" {
const int nkey,
uint16_t vbucket)
{
get_options_t options = static_cast<get_options_t>(QUEUE_BG_FETCH |
HONOR_STATES |
TRACK_REFERENCE |
DELETE_TEMP |
HIDE_LOCKED_CAS |
TRACK_STATISTICS);

ENGINE_ERROR_CODE err_code = getHandle(handle)->get(cookie, itm, key,
nkey, vbucket,
TRACK_STATISTICS);
options);
releaseHandle(handle);
return err_code;
}
Expand Down Expand Up @@ -2288,8 +2295,14 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::store(const void *cookie,
case OPERATION_PREPEND: {
bool locked = false;
do {
get_options_t options = static_cast<get_options_t>(QUEUE_BG_FETCH |
HONOR_STATES |
TRACK_REFERENCE |
DELETE_TEMP |
HIDE_LOCKED_CAS);
if ((ret = get(cookie, &i, it->getKey().c_str(),
it->getNKey(), vbucket)) == ENGINE_SUCCESS) {
it->getNKey(), vbucket,
options)) == ENGINE_SUCCESS) {
Item *old = reinterpret_cast<Item *>(i);
locked = old->getCas() == uint64_t(-1);

Expand Down
8 changes: 5 additions & 3 deletions src/ep_engine.h
Expand Up @@ -288,12 +288,12 @@ class EventuallyPersistentEngine : public ENGINE_HANDLE_V1 {
const void* key,
const int nkey,
uint16_t vbucket,
get_options_t options = NONE)
get_options_t options)
{
BlockTimer timer(&stats.getCmdHisto);
std::string k(static_cast<const char*>(key), nkey);

GetValue gv(epstore->get(k, vbucket, cookie));
GetValue gv(epstore->get(k, vbucket, cookie, options));
ENGINE_ERROR_CODE ret = gv.getStatus();

if (ret == ENGINE_SUCCESS) {
Expand Down Expand Up @@ -360,7 +360,9 @@ class EventuallyPersistentEngine : public ENGINE_HANDLE_V1 {
0 : ep_abs_time(ep_reltime(exptime));

get_options_t options = static_cast<get_options_t>(QUEUE_BG_FETCH |
TRACK_REFERENCE | HONOR_STATES);
HONOR_STATES |
TRACK_REFERENCE |
HIDE_LOCKED_CAS);

ENGINE_ERROR_CODE ret = get(cookie, &it, key, nkey, vbucket, options);
if (ret == ENGINE_SUCCESS) {
Expand Down
22 changes: 22 additions & 0 deletions tests/ep_testsuite_basic.cc
Expand Up @@ -1433,6 +1433,26 @@ static enum test_result test_incr_miss(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
return SUCCESS;
}


// The following test requires a configuration where the bloom filter is
// disabled. If the bloom filter is enabled it can check to see if the item
// exists and therefore avoids creating a temporary item.

static enum test_result test_incr_mb20425(ENGINE_HANDLE *h,
ENGINE_HANDLE_V1 *h1) {
uint64_t result = 0;
item *i = NULL;

checkeq(ENGINE_SUCCESS,
h1->arithmetic(h, NULL, "key", 3, true, true, 1, 1, 0, &i,
PROTOCOL_BINARY_RAW_BYTES, &result, 0),
"Failed arithmetic operation");
h1->release(h, NULL, i);
checkeq(uint64_t(1), result,
"Failed to set initial value in arithmetic operation");
return SUCCESS;
}

static enum test_result test_incr(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) {
const void *cookie = testHarness.create_cookie();
testHarness.set_datatype_support(cookie, true);
Expand Down Expand Up @@ -2574,6 +2594,8 @@ BaseTestCase testsuite_testcases[] = {
NULL, prepare, cleanup),
TestCase("incr miss", test_incr_miss, test_setup,
teardown, NULL, prepare, cleanup),
TestCase("incr (MB-20425)", test_incr_mb20425, test_setup,
teardown, "bfilter_enabled=false", prepare, cleanup),
TestCase("incr", test_incr, test_setup, teardown, NULL,
prepare, cleanup),
TestCase("incr with default", test_incr_default,
Expand Down

0 comments on commit 3fc5e69

Please sign in to comment.