orientechnologies / orientdb

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
https://orientdb.dev
Apache License 2.0
4.72k stars 870 forks source link

Database backup leads to index failures #10224

Open jacquipre opened 2 months ago

jacquipre commented 2 months ago

OrientDB Version: 3.2.22

Java Version: 17.0.10

OS: Windows

Expected behavior

Database backup does not corrupt indices.

Actual behavior

When making a backup via

try (ODatabaseDocumentTx db = // acquire database from pool ) {
            OCommandOutputListener listener = // logs somethings

            try (OutputStream out = new FileOutputStream(path)) {
                db.backup(out, null, null, listener, 1, 2048);
            }
}

sometimes an exception is thrown:

SEVERE: Exception `1CE43CF2` in storage `plocal:/data/database`: 3.2.22 (build ${buildNumber}, branch UNKNOWN)
java.lang.NullPointerException: Cannot invoke "com.orientechnologies.orient.core.record.impl.ODocument.containsField(String)" because "metadata" is null
        at com.orientechnologies.lucene.engine.OLuceneDirectoryFactory.createDirectory(OLuceneDirectoryFactory.java:31)
        at com.orientechnologies.lucene.engine.OLuceneIndexEngineAbstract.open(OLuceneIndexEngineAbstract.java:249)
        at com.orientechnologies.lucene.engine.OLuceneIndexEngineAbstract.reOpen(OLuceneIndexEngineAbstract.java:236)
        at com.orientechnologies.lucene.engine.OLuceneIndexEngineAbstract.release(OLuceneIndexEngineAbstract.java:665)
        at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.release(OAbstractPaginatedStorage.java:4192)
        at com.orientechnologies.orient.core.storage.disk.OLocalPaginatedStorage.backup(OLocalPaginatedStorage.java:289)
        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.backup(ODatabaseDocumentEmbedded.java:1912)
        at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.backup(ODatabaseDocumentTx.java:1326)

Not sure why this happened.

It leads to a removal of all database and lucene (only RAM type) indizes in the index manager. When loading the database, I can see that no index is found anymore, although all index files are currently available in the database directory.

Do you have any ideas what can lead to such a database behaviour? How can we fix the database? Is there a possibility?

I saw an issue about same errors: https://github.com/orientechnologies/orientdb/issues/8813

What was the resolution here?

Regards, j.

jacquipre commented 1 month ago

Hi, I found out that there is a lucene index (type: RAM) registered in the indexEngines List of OAbstractPaginatedStorage which is marked as closed and has metadata = null. When requesting this index via the OIndexManager with getClassIndexes(String indexName) this index does not exist.

We are making a backup of the database every night at the same time. I guess, this index gets "corrupted" while freezing those Lucene indexes in com.orientechnologies.orient.core.storage.disk.OLocalPaginatedStorage#backup (Line 244 calls freeze(...)) Here those indices were closed. When the backup is done, this index is not released (unfreezed) anymore.

Is there any possibility to get rid of this corrupted index? I tried dropping it or even call deleteIndexEngine(indexId) but this all leads to the same error?