eclipse-zenoh / zenoh-backend-rocksdb

Backend and Storages for zenoh using RocksDB
Other
12 stars 12 forks source link

[Bug] Corruption: unknown checksum type 4 #171

Open mbspng opened 4 weeks ago

mbspng commented 4 weeks ago

Describe the bug

Publishing data to RocksDB results in Corruption: unknown checksum type 4 when querying. I found this thread, which might be related: https://bugzilla.redhat.com/show_bug.cgi?id=2193399

To reproduce

Script to put data into DB


session = zenoh.open()
pub = session.declare_publisher("data/store")
pub.put("1")  # putting byte string results in same error.

Script to query database


import argparse
from pathlib import Path

import rocksdb

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("rocksdb_directory", type=Path)
    return parser.parse_args()

def main(args):
    column_families = {
        b"default": rocksdb.ColumnFamilyOptions(),
        b"data_info": rocksdb.ColumnFamilyOptions(),
    }

    options = rocksdb.Options(create_if_missing=False)
    db = rocksdb.DB(
        str(args.rocksdb_directory),
        options,
        column_families=column_families,
        read_only=True,
    )

if __name__ == "__main__":
    main(parse_args())

Error

Traceback (most recent call last):
  File "...query_rocksdb.py", line 42, in <module>
    main(parse_args())
  File ".../query_rocksdb.py", line 22, in main
    db = rocksdb.DB(
  File "rocksdb/_rocksdb.pyx", line 1636, in rocksdb._rocksdb.DB.__cinit__
  File "rocksdb/_rocksdb.pyx", line 76, in rocksdb._rocksdb.check_status
rocksdb.errors.Corruption: b'Corruption: unknown checksum type 4 in zenoh-rocksdb/example/000028.sst offset 25692519 size 35'

System info

Ubuntu 22.04

-> % dpkg -l G rocksdb
ii  librocksdb-dev                                6.11.4-3                                    amd64        persistent Key-Value Store for Flash and RAM Storage (development)
ii  librocksdb6.11                                6.11.4-3                                    amd64        persistent Key-Value Store for Flash and RAM Storage
ii  zenoh-backend-rocksdb                         0.11.0-stable                               amd64        Backend for Zenoh using RocksDB

-> % dpkg -l G zenoh  
ii  zenoh                                         0.11.0-stable                               amd64        Zenoh: Zero Overhead Pub/sub, Store/Query and Compute.
ii  zenoh-backend-rocksdb                         0.11.0-stable                               amd64        Backend for Zenoh using RocksDB
ii  zenoh-plugin-rest                             0.11.0-stable                               amd64        The zenoh REST plugin
ii  zenoh-plugin-storage-manager                  0.11.0-stable                               amd64        The zenoh storages plugin.
ii  zenohd                                        0.11.0-stable                               amd64        Zenoh: Zero Overhead Pub/sub, Store/Query and Compute.

-> % pip list G rocks 
python-rocksdb        0.7.0
mbspng commented 3 weeks ago

The bug is that using a key expression in the storage config for RocksDB that ends in ** will cause this. Is this expected? Other storages can have ** in the key expression.

So my config was

{
  plugins: {
    rest: {                        // activate and configure the REST plugin
      http_port: 8000              // with HTTP server listening on port 8000
    },
    storage_manager: {             // activate and configure the storage_manager plugin
      volumes: {
        rocksdb: {
        }
      },
      storages: {
        rocksdb: {
          // the key expression this storage will subscribe to
          key_expr: "point_clouds/**",
          // this prefix will be stripped from the received key when converting to database key.
          // i.e.: "demo/example/a/b" will be stored as "a/b"
          //          strip_prefix: "demo/example",
          volume: {
            id: "rocksdb",
            // the RocksDB database will be stored in this directory (relative to ${ZENOH_BACKEND_ROCKSDB_ROOT})
            dir: "example",
            // create the RocksDB database if not already existing
            create_db: true
          }
        }
      }
    }
  }
}

And I changed it to

{
  plugins: {
    rest: {                        // activate and configure the REST plugin
      http_port: 8000              // with HTTP server listening on port 8000
    },
    storage_manager: {             // activate and configure the storage_manager plugin
      volumes: {
        rocksdb: {
        }
      },
      storages: {
        rocksdb: {
          // the key expression this storage will subscribe to
          key_expr: "point_clouds/store",
          // this prefix will be stripped from the received key when converting to database key.
          // i.e.: "demo/example/a/b" will be stored as "a/b"
          //          strip_prefix: "demo/example",
          volume: {
            id: "rocksdb",
            // the RocksDB database will be stored in this directory (relative to ${ZENOH_BACKEND_ROCKSDB_ROOT})
            dir: "example",
            // create the RocksDB database if not already existing
            create_db: true
          }
        }
      }
    }
  }
}

by dropping the **. Then the error went away and I could successfully query the RocksDB.

oteffahi commented 1 week ago

Hello @mbspng. Thank you for investigating and reporting this issue. I will address it asap 👍