rosedblabs / rosedb

Lightweight, fast and reliable key/value storage engine based on Bitcask.
https://rosedblabs.github.io
Apache License 2.0
4.48k stars 620 forks source link

rose.Get panil #302

Closed EternalHunters closed 4 months ago

EternalHunters commented 5 months ago

I think a nil check should be added

problem code:

func (it *item) Less(bi btree.Item) bool {
    return bytes.Compare(it.key, bi.(*item).key) < 0
}

trace stack:

panic: interface conversion: btree.Item is nil, not *index.item

goroutine 45976651194 [running]:
github.com/rosedblabs/rosedb/v2/index.(*item).Less(0xc03a835ec0, {0x0, 0x0})
        /data/go/pkg/mod/github.com/rosedblabs/rosedb/v2@v2.3.4/index/btree.go:31 +0xd5
github.com/google/btree.glob..func1({0x1a79740, 0xc03a835ec0}, {0x0, 0x0})
        /data/go/pkg/mod/github.com/google/btree@v1.1.2/btree_generic.go:905 +0x49
github.com/google/btree.items[...].find.func1()
        /data/go/pkg/mod/github.com/google/btree@v1.1.2/btree_generic.go:216 +0xa9
sort.Search(0x3b, 0xc00db4f268)
        /data/jenkins/tools/org.jenkinsci.plugins.golang.GolangInstallation/Go1.20.5/src/sort/search.go:65 +0x65
github.com/google/btree.items[...].find(0x1a8b860, {0x1a79740, 0xc03a835ec0}, 0x19efb88)
        /data/go/pkg/mod/github.com/google/btree@v1.1.2/btree_generic.go:215 +0x15b
github.com/google/btree.(*node[...]).get(0x1aa1e80, {0x1a79740, 0xc03a835ec0})
        /data/go/pkg/mod/github.com/google/btree@v1.1.2/btree_generic.go:322 +0xdc
github.com/google/btree.(*node[...]).get(0x1aa1e80, {0x1a79740, 0xc03a835ec0})
        /data/go/pkg/mod/github.com/google/btree@v1.1.2/btree_generic.go:326 +0x1f3
github.com/google/btree.(*node[...]).get(0x1aa1e80, {0x1a79740, 0xc03a835ec0})
        /data/go/pkg/mod/github.com/google/btree@v1.1.2/btree_generic.go:326 +0x1f3
github.com/google/btree.(*BTreeG[...]).Get(0x1aa1bc0, {0x1a79740, 0xc03a835ec0})
        /data/go/pkg/mod/github.com/google/btree@v1.1.2/btree_generic.go:824 +0x99
github.com/google/btree.(*BTree).Get(0xc018bd5860, {0x1a79740, 0xc03a835ec0})
        /data/go/pkg/mod/github.com/google/btree@v1.1.2/btree_generic.go:977 +0x5a
github.com/rosedblabs/rosedb/v2/index.(*MemoryBTree).Get(0xc00501aec0, {0xc03adf5578, 0x12, 0x18})
        /data/go/pkg/mod/github.com/rosedblabs/rosedb/v2@v2.3.4/index/btree.go:46 +0xe6
github.com/rosedblabs/rosedb/v2.(*Batch).Get(0xc0485fede0, {0xc03adf5578, 0x12, 0x18})
        /data/go/pkg/mod/github.com/rosedblabs/rosedb/v2@v2.3.4/batch.go:207 +0x3b8
roseduan commented 5 months ago

Thanks, how to reproduce the problem?

EternalHunters commented 5 months ago

Thanks, how to reproduce the problem?

sorry, i don't know how to reproduce,I only encountered it in the prod environment, and I haven’t found the data scenario yet.

roseduan commented 5 months ago

Thanks, how to reproduce the problem?

sorry, i don't know how to reproduce,I only encountered it in the prod environment, and I haven’t found the data scenario yet.

Thanks for your feedback. I will fix this by adding a nil check.

EternalHunters commented 4 months ago

Thanks, how to reproduce the problem?

sorry, i don't know how to reproduce,I only encountered it in the prod environment, and I haven’t found the data scenario yet.

Thanks for your feedback. I will fix this by adding a nil check.

Is there an estimated repair time?

roseduan commented 4 months ago

Thanks, how to reproduce the problem?

sorry, i don't know how to reproduce,I only encountered it in the prod environment, and I haven’t found the data scenario yet.

Thanks for your feedback. I will fix this by adding a nil check.

Is there an estimated repair time?

https://github.com/rosedblabs/rosedb/releases/tag/v2.3.5 Fixed in the latest release.

EternalHunters commented 4 months ago

Thanks, how to reproduce the problem?

sorry, i don't know how to reproduce,I only encountered it in the prod environment, and I haven’t found the data scenario yet.

Thanks for your feedback. I will fix this by adding a nil check.

Is there an estimated repair time?

https://github.com/rosedblabs/rosedb/releases/tag/v2.3.5 Fixed in the latest release. When you have time, you can take a look at the scenarios in which this problem occurs.

EternalHunters commented 4 months ago

Thanks, how to reproduce the problem?

sorry, i don't know how to reproduce,I only encountered it in the prod environment, and I haven’t found the data scenario yet.

Thanks for your feedback. I will fix this by adding a nil check.

Is there an estimated repair time?

https://github.com/rosedblabs/rosedb/releases/tag/v2.3.5 Fixed in the latest release.

image

after update still panic

EternalHunters commented 4 months ago

![Uploading Xnip2024-03-06_10-11-59.jpg…]()

roseduan commented 4 months ago

Can you give me an example code to reproduce the problem?

roseduan commented 4 months ago

Are you still having problems with this issue? @EternalHunters