Skip to content

Commit 5057149

Browse files
committed
MB-41107: Add conflict_resolution_type=custom (dev preview)
Add a third enumeration value for conflict_resolution_type: 'custom'. This is currently treated identically to the "lww" value. Change-Id: Ib0f191bf3068c15bb3dd3cb5a7a165a9a77fc4c3 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/137549 Tested-by: Build Bot <[email protected]> Reviewed-by: James Harrison <[email protected]>
1 parent d00407c commit 5057149

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

engines/ep/configuration.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,14 @@
229229
},
230230
"conflict_resolution_type": {
231231
"default": "seqno",
232+
"desr": "Conflict resolution mode to use for this Bucket",
232233
"dynamic": false,
233234
"type": "std::string",
234235
"validator": {
235236
"enum": [
236237
"seqno",
237-
"lww"
238+
"lww",
239+
"custom"
238240
]
239241
}
240242
},

engines/ep/src/ep_engine.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5259,13 +5259,13 @@ bool EventuallyPersistentEngine::decodeWithMetaOptions(
52595259
bool check1 = generateCas == GenerateCas::Yes &&
52605260
checkConflicts == CheckConflicts::Yes;
52615261

5262-
// 2) If bucket is LWW and forceFlag is not set and GenerateCas::No
5263-
bool check2 = configuration.getConflictResolutionType() == "lww" &&
5262+
// 2) If bucket is LWW/Custom and forceFlag is not set and GenerateCas::No
5263+
bool check2 = configuration.getConflictResolutionType() != "seqno" &&
52645264
!forceFlag && generateCas == GenerateCas::No;
52655265

5266-
// 3) If bucket is not LWW then forceFlag must be false.
5266+
// 3) If bucket is seqno then forceFlag must be false.
52675267
bool check3 =
5268-
configuration.getConflictResolutionType() != "lww" && forceFlag;
5268+
configuration.getConflictResolutionType() == "seqno" && forceFlag;
52695269

52705270
// So if either check1/2/3 is true, return false
52715271
return !(check1 || check2 || check3);

engines/ep/src/vbucket.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ VBucket::VBucket(Vbid i,
240240
seqnoAckCb(std::move(seqnoAckCb)),
241241
manifest(std::move(manifest)),
242242
mayContainXattrs(mightContainXattrs) {
243-
if (config.getConflictResolutionType().compare("lww") == 0) {
244-
conflictResolver.reset(new LastWriteWinsResolution());
243+
if (config.getConflictResolutionType() == "seqno") {
244+
conflictResolver = std::make_unique<RevisionSeqnoResolution>();
245245
} else {
246-
conflictResolver.reset(new RevisionSeqnoResolution());
246+
// Both last-write-wins and custom conflict resolution are treated
247+
// as LWW from KV-Engine's pov.
248+
conflictResolver = std::make_unique<LastWriteWinsResolution>();
247249
}
248250

249251
pendingOpsStart = std::chrono::steady_clock::time_point();

0 commit comments

Comments
 (0)