Skip to content

Commit

Permalink
rocksdb: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Dec 19, 2023
1 parent a8bd21a commit 73a3afc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions go/storage/mkvs/db/rocksdb/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ func (itr *iterator) Key() []byte {
return copyAndFreeSlice(itr.source.Key())
}

func (itr *iterator) Timestamp() []byte {
itr.assertIsValid()
return copyAndFreeSlice(itr.source.Timestamp())
}

func (itr *iterator) Value() []byte {
itr.assertIsValid()
return copyAndFreeSlice(itr.source.Value())
Expand Down
12 changes: 6 additions & 6 deletions go/storage/mkvs/db/rocksdb/rocksdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func newOptions(versioned bool, maxCacheSize int64) *grocksdb.Options {

// TODO: Consider separate options for state vs. io.
opts := grocksdb.NewDefaultOptions()
opts.SetParanoidChecks(true)
// opts.SetParanoidChecks(true)
opts.SetCreateIfMissing(true)
if versioned {
opts.SetComparator(createTimestampComparator())
Expand Down Expand Up @@ -828,23 +828,23 @@ func (d *rocksdbNodeDB) Prune(ctx context.Context, version uint64) error {

itRo := timestampReadOptions(root.Version)
defer itRo.Destroy()
s, ts, err := d.db.GetCFWithTS(itRo, cf, nodeKeyFmt.Encode(&h))
s, itemTs, err := d.db.GetCFWithTS(itRo, cf, nodeKeyFmt.Encode(&h))
if err != nil {
return false
}
defer s.Free()
if !s.Exists() {
ts.Free()
itemTs.Free()
return false
}

itemTs, err := versionFromTimestamp(ts)
itemVersion, err := versionFromTimestamp(itemTs)
if err != nil {
// Shouldn't happen unless corrupted db.
panic(fmt.Errorf("mkvs/rocksdb: missing/corrupted timestamp for node: %s", h))
}
if itemTs == version {
batch.DeleteCFWithTS(cf, nodeKeyFmt.Encode(&h), ts.Data())
if itemVersion == version {
batch.DeleteCFWithTS(cf, nodeKeyFmt.Encode(&h), ts[:])
}
return true
})
Expand Down

0 comments on commit 73a3afc

Please sign in to comment.