Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: no command to fix corrupted data in versiondb #1685

Merged
merged 30 commits into from
Nov 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion versiondb/tsrocksdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
prependStoreKey(storeKey, key),
)
if err != nil {
return nil, err
}

Check warning on line 104 in versiondb/tsrocksdb/store.go

View check run for this annotation

Codecov / codecov/patch

versiondb/tsrocksdb/store.go#L103-L104

Added lines #L103 - L104 were not covered by tests
defer ts.Free()

if value.Exists() && s.skipVersionZero {
Expand All @@ -125,7 +125,7 @@
// HasAtVersion implements VersionStore interface
func (s Store) HasAtVersion(storeKey string, key []byte, version *int64) (bool, error) {
slice, err := s.GetAtVersionSlice(storeKey, key, version)
if err != nil {
if err != nil || slice == nil {
yihuang marked this conversation as resolved.
Show resolved Hide resolved
return false, err
}
defer slice.Free()
Expand Down Expand Up @@ -238,8 +238,8 @@
func (s Store) FixData(storeNames []string) error {
for _, storeName := range storeNames {
if err := s.fixDataStore(storeName); err != nil {
return err
}

Check warning on line 242 in versiondb/tsrocksdb/store.go

View check run for this annotation

Codecov / codecov/patch

versiondb/tsrocksdb/store.go#L241-L242

Added lines #L241 - L242 were not covered by tests
}

return nil
Expand All @@ -250,8 +250,8 @@
var version int64
iter, err := s.IteratorAtVersion(storeName, nil, nil, &version)
if err != nil {
return err
}

Check warning on line 254 in versiondb/tsrocksdb/store.go

View check run for this annotation

Codecov / codecov/patch

versiondb/tsrocksdb/store.go#L253-L254

Added lines #L253 - L254 were not covered by tests
defer iter.Close()

batch := grocksdb.NewWriteBatch()
Expand All @@ -261,8 +261,8 @@
for ; iter.Valid(); iter.Next() {
key := iter.Key()
if len(key) < TimestampSize {
return fmt.Errorf("invalid key length: %X, store: %s", key, storeName)
}

Check warning on line 265 in versiondb/tsrocksdb/store.go

View check run for this annotation

Codecov / codecov/patch

versiondb/tsrocksdb/store.go#L264-L265

Added lines #L264 - L265 were not covered by tests

ts := key[len(key)-TimestampSize:]
key = key[:len(key)-TimestampSize]
Expand All @@ -272,15 +272,15 @@
readOpts.SetTimestamp(ts)
oldValue, err := s.db.GetCF(readOpts, s.cfHandle, realKey)
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}

Check warning on line 276 in versiondb/tsrocksdb/store.go

View check run for this annotation

Codecov / codecov/patch

versiondb/tsrocksdb/store.go#L275-L276

Added lines #L275 - L276 were not covered by tests
readOpts.Destroy()

clean := bytes.Equal(oldValue.Data(), iter.Value())
oldValue.Free()

if clean {
continue

Check warning on line 283 in versiondb/tsrocksdb/store.go

View check run for this annotation

Codecov / codecov/patch

versiondb/tsrocksdb/store.go#L283

Added line #L283 was not covered by tests
}

batch.PutCFWithTS(s.cfHandle, realKey, ts, iter.Value())
Expand Down
Loading