Skip to content

Using Snapshots in other classes #134

@platacc

Description

@platacc

Hello,

I have followed the documentation and there is limited information on how to use Snapshots in other methods and classes. When I open a database instance, take a snapshot, then export it to a new method, the entire JVM crashes which I have never seen before:

A fatal error has been detected by the Java Runtime Environment:

Here is how I am grabbing the Snapshot:

    public synchronized DBIterator getSnapShot() throws IOException {

        ReadOptions options = new ReadOptions();
        
        DBIterator iterator = null;

        try {
            setLinkPacDatabase(factory.open(new File(Finals.LINKPACDB_FILEPATH), setupLevelDbOptions(true, false)));
            options.snapshot(getLinkPacDatabase().getSnapshot());
            iterator = getLinkPacDatabase().iterator(options);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            getLinkPacDatabase().close();
        }
        return iterator;
    }

But when I try to iterate the Snapshot like below in other classes, the JVM crashes:

    for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) {

What is the correct way to take a Snapshot of the database and use it elsewhere?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions