-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
Storage 2017-05-29, Storage 2017-06-19, Storage 2017-07-10, Storage 2017-07-31, Storage 2017-08-21
-
0
Change WiredTigerRecordStore::updateWithDamages to use WiredTiger's WT_CURSOR.modify support.
The following change passes the storage_wiredtiger_record_store_test test.
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index e9f7787..3b4f4a4 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -1449,7 +1449,7 @@ Status WiredTigerRecordStore::updateRecord(OperationContext* opCtx, } bool WiredTigerRecordStore::updateWithDamagesSupported() const { - return false; + return true; } StatusWith<RecordData> WiredTigerRecordStore::updateWithDamages( @@ -1458,7 +1458,36 @@ StatusWith<RecordData> WiredTigerRecordStore::updateWithDamages( const RecordData& oldRec, const char* damageSource, const mutablebson::DamageVector& damages) { - MONGO_UNREACHABLE; + + int nentries = damages.size(); + mutablebson::DamageVector::const_iterator where = damages.begin(); + const mutablebson::DamageVector::const_iterator end = damages.end(); + WT_MODIFY entries[nentries]; + for (u_int i = 0; where != end; ++i, ++where) { + entries[i].data.data = damageSource + where->sourceOffset; + entries[i].data.size = where->size; + entries[i].offset = where->targetOffset; + entries[i].size = where->size; + } + + WiredTigerCursor curwrap(_uri, _tableId, true, opCtx); + curwrap.assertInActiveTxn(); + WT_CURSOR* c = curwrap.get(); + invariant(c); + c->set_key(c, _makeKey(id)); + + // The test harness calls us with empty damage vectors which WiredTiger doesn't allow. + if (nentries == 0) + invariantWTOK(WT_OP_CHECK(c->search(c))); + else + invariantWTOK(WT_OP_CHECK(c->modify(c, entries, nentries))); + + WT_ITEM value; + invariantWTOK(c->get_value(c, &value)); + + SharedBuffer data = SharedBuffer::allocate(value.size); + memcpy(data.get(), value.data, value.size); + return RecordData(data, value.size); }
- depends on
-
WT-2972 Add interface allowing partial updates to existing values
- Closed