Skip to content

Commit 2a99eaf

Browse files
committed
query with GetCFWithTS to compare both timestamp and key
1 parent 75ba941 commit 2a99eaf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

versiondb/tsrocksdb/store.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,24 +262,25 @@ func (s Store) fixDataStore(storeName string, dryRun bool) error {
262262
prefix := storePrefix(storeName)
263263
readOpts := grocksdb.NewDefaultReadOptions()
264264
defer readOpts.Destroy()
265+
265266
for _, pair := range pairs {
266267
realKey := cloneAppend(prefix, pair.Key)
267268

268269
readOpts.SetTimestamp(pair.Timestamp)
269-
oldValue, err := s.db.GetCF(readOpts, s.cfHandle, realKey)
270+
oldValue, oldTimestamp, err := s.db.GetCFWithTS(readOpts, s.cfHandle, realKey)
270271
if err != nil {
271272
return err
272273
}
273274

274-
clean := bytes.Equal(oldValue.Data(), pair.Value)
275+
clean := bytes.Equal(oldValue.Data(), pair.Value) && bytes.Equal(oldTimestamp.Data(), pair.Timestamp)
275276
oldValue.Free()
276-
277+
oldTimestamp.Free()
277278
if clean {
278279
continue
279280
}
280281

281282
if dryRun {
282-
fmt.Printf("fix data: %s, key: %X, ts: %X\n", storeName, pair.Key, pair.Timestamp)
283+
fmt.Printf("fix data: %s, key: %X, ts: %X, %X\n", storeName, pair.Key, pair.Timestamp, pair.Value)
283284
} else {
284285
batch.PutCFWithTS(s.cfHandle, realKey, pair.Timestamp, pair.Value)
285286
}

0 commit comments

Comments
 (0)