surrealdb / surrealkv

A low-level, versioned, embedded, ACID-compliant, key-value database for Rust
https://surrealdb.com
Apache License 2.0
232 stars 16 forks source link

Range end index out of range after restarting database #71

Closed Luxbit closed 2 weeks ago

Luxbit commented 2 weeks ago

Over the last few days, when restarting surrealdb 2.0.0-alpha.9, the storage file got corrupted.

Reading the file returns the following error on startup

 2024-08-24T20:26:10.710000Z  INFO surreal::env: Running 2.0.0-alpha.9 for linux on aarch64
 2024-08-24T20:26:10.710130Z  INFO surrealdb::core::kvs::tr: Starting kvs store at surrealkv:///data/store.surrealkv
 thread 'main' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/surrealkv-0.3.0/src/storage/kv/reader.rs:70:55:
 range end index 35024 out of range for slice of length 3276

I have not changed any versions for surrealkv or surrealdb. Surrealdb is running in a Docker container with an attached volume

arriqaaq commented 2 weeks ago

Thank you @Luxbit for reporting this. Is it possible to understand the data that is stored on disk to decipher this further (data dump or anything as such)?

Luxbit commented 2 weeks ago

I will try to reproduce this issue with less data so it is more convenient to debug. The corrupted files were around 100Mb.

arriqaaq commented 2 weeks ago

Thanks @Luxbit

arriqaaq commented 2 weeks ago

Also, could you please verify if the same error reproducible in the latest version of alpha release? Currently surrealkv is at 0.3.4 (it is 0.3.0 in the error reported above), and just wanted to ensure if it is a bug which is already fixed as the logic around the reader has been modified in the latest release. In case you are testing it, I'dsuggest to use the latest alpha release version for this

Luxbit commented 2 weeks ago

Also, could you please verify if the same error reproducible in the latest version of alpha release? Currently surrealkv is at 0.3.4 (it is 0.3.0 in the error reported above), and just wanted to ensure if it is a bug which is already fixed as the logic around the reader has been modified in the latest release. In case you are testing it, I'dsuggest to use the latest alpha release version for this

Good to know, I will upgrade to the latest version. I will test this later today

Luxbit commented 2 weeks ago

Closing this for now. I have been using the latest build for the last 2 days and I could not reproduce the issue.

arriqaaq commented 2 weeks ago

Please feel free to reopen @Luxbit if you come across it again