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

TtlDb.java doesn't set default column family handle #12411

Open
dtanner opened this issue Mar 6, 2024 · 4 comments
Open

TtlDb.java doesn't set default column family handle #12411

dtanner opened this issue Mar 6, 2024 · 4 comments

Comments

@dtanner
Copy link

dtanner commented Mar 6, 2024

Expected behavior

TtlDb.java newIterator() should successfully use the default column family handle similar to how it works when using RocksDB.java.

Actual behavior

It fails with:

java.lang.NullPointerException: Cannot read field "nativeHandle_" because "this.defaultColumnFamilyHandle_" is null
	at org.rocksdb.RocksDB.newIterator(RocksDB.java:3241)

because the defaultColumnFamilyHandle_ wasn't set up in the 2 and 4 arg open methods of TtlDb.
e.g. RocksDB's open implementation that configures the default column family handle:

  public static RocksDB open(final Options options, final String path)
      throws RocksDBException {
    final RocksDB db = new RocksDB(open(options.nativeHandle_, path));
    db.storeOptionsInstance(options);
    db.storeDefaultColumnFamilyHandle(db.makeDefaultColumnFamilyHandle()); // <---- 
    return db;
  }

Contrast that with TtlDB.java's open method that accepts an Option:

  public static TtlDB open(final Options options, final String db_path,
      final int ttl, final boolean readOnly) throws RocksDBException {
    return new TtlDB(open(options.nativeHandle_, db_path, ttl, readOnly));
  }

Steps to reproduce the behavior

Instead of a RocksDb, configure a TtlDB with Options and try using an iterator.

@dtanner
Copy link
Author

dtanner commented Mar 6, 2024

I'm happy to submit a PR that configures the default column family handle in TtlDB, but maybe there's a good reason it behaves differently?

@alanpaxton
Copy link
Contributor

Thank you @dtanner - I think it's just a straightforward error on our part; I'll see if I can organise a fix just now..

@alanpaxton
Copy link
Contributor

FYI @dtanner this was fixed in the PR #12167 - are you using the most recent released version of rocksdbjni ?

@alanpaxton
Copy link
Contributor

And of course it turns out that there are related issues in other RocksDB subclasses, plus a lot of inconsistency . I have addressed these in #12417

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants