if (vb->getState() != vbucket_state_active) {
return wantDeleted ? v : NULL;
}
- if (queueExpired) {
+ ReaderLockHolder(vb->getStateLock());
+ // queueDirty only allowed on active VB
+ if (queueExpired && vb->getState() == vbucket_state_active) {
incExpirationStat(vb, false);
vb->ht.unlocked_softDelete(v, 0, eviction_policy);
- queueDirty(vb, v, NULL, false, true);
+ queueDirty(vb, v, NULL, NULL, false, true);
}
return wantDeleted ? v : NULL;
}
}
}
-ENGINE_ERROR_CODE EventuallyPersistentStore::addTAPBackfillItem(const Item &itm,
- uint8_t nru,
- bool genBySeqno) {
+ENGINE_ERROR_CODE EventuallyPersistentStore::addTAPBackfillItem(
+ const Item &itm,
+ uint8_t nru,
+ bool genBySeqno,
+ ExtendedMetaData *emd) {
RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
- if (!vb ||
- vb->getState() == vbucket_state_dead ||
+ if (!vb) {
+ ++stats.numNotMyVBuckets;
+ return ENGINE_NOT_MY_VBUCKET;
+ }
+
+ // Obtain read-lock on VB state to ensure VB state changes are interlocked
+ // with this add-tapbackfill
+ ReaderLockHolder(vb->getStateLock());
+ if (vb->getState() == vbucket_state_dead ||
vb->getState() == vbucket_state_active) {
++stats.numNotMyVBuckets;
return ENGINE_NOT_MY_VBUCKET;
}
}
-ENGINE_ERROR_CODE EventuallyPersistentStore::setWithMeta(const Item &itm,
- uint64_t cas,
- const void *cookie,
- bool force,
- bool allowExisting,
- uint8_t nru,
- bool genBySeqno,
- bool isReplication)
+ENGINE_ERROR_CODE EventuallyPersistentStore::setWithMeta(
+ const Item &itm,
+ uint64_t cas,
+ uint64_t *seqno,
+ const void *cookie,
+ bool force,
+ bool allowExisting,
+ uint8_t nru,
+ bool genBySeqno,
+ ExtendedMetaData *emd,
+ bool isReplication)
{
RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
- if (!vb || vb->getState() == vbucket_state_dead) {
+ if (!vb) {
+ ++stats.numNotMyVBuckets;
+ return ENGINE_NOT_MY_VBUCKET;
+ }
+
+ ReaderLockHolder(vb->getStateLock());
+ if (vb->getState() == vbucket_state_dead) {
++stats.numNotMyVBuckets;
return ENGINE_NOT_MY_VBUCKET;
} else if (vb->getState() == vbucket_state_replica && !force) {
ENGINE_SUCCESS, v->getBySeqno());
if (exptime_mutated) {
- // persist the item in the underlying storage for
- // mutated exptime
- queueDirty(vb, v, &lh, NULL);
+ ReaderLockHolder(vb->getStateLock());
+ if (vb->getState() == vbucket_state_active) {
+ // persist the item in the underlying storage for
+ // mutated exptime but only if VB is active.
- queueDirty(vb, v, &lh);
++ queueDirty(vb, v, &lh, NULL);
+ }
}
return rv;
} else {
TestCase("test failover log behavior", test_failover_log_behavior,
test_setup, teardown, NULL, prepare, cleanup),
+
+#if defined(HAVE_JEMALLOC)
+ TestCase("test defragmenter", test_defragmenter,
+ test_setup, teardown,
+ "defragmenter_interval=9999"
+ ";defragmenter_age_threshold=0"
+ ";defragmenter_chunk_duration=99999",
+ prepare, cleanup),
+#endif
+
+ TestCase("test hlc cas", test_hlc_cas, test_setup, teardown,
+ NULL, prepare, cleanup),
TestCase("test get all vb seqnos", test_get_all_vb_seqnos, test_setup,
teardown, NULL, prepare, cleanup),
-
+ #if !defined(THREAD_SANITIZER)
TestCase("test MB-16357", test_mb16357,
test_setup, teardown, "compaction_exp_mem_threshold=85",
prepare, cleanup),