|
@@ -137,6 +137,21 @@ public class XodusLocalDB implements LocalDBProvider
|
|
|
|
|
|
LOGGER.trace( () -> "preparing to open with configuration " + JsonUtil.serializeMap( environmentConfig.getSettings() ) );
|
|
|
environment = Environments.newInstance( dbDirectory.getAbsolutePath() + File.separator + FILE_SUB_PATH, environmentConfig );
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if ( getDirtyFile().exists() )
|
|
|
+ {
|
|
|
+ Files.createFile( getDirtyFile().toPath() );
|
|
|
+ LOGGER.trace( () -> "created openLock file" );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch ( IOException e )
|
|
|
+ {
|
|
|
+ LOGGER.error( "error creating openLock file: " + e.getMessage() );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
LOGGER.trace( () -> "environment open (" + TimeDuration.fromCurrent( startTime ).asCompactString() + ")" );
|
|
|
|
|
|
environment.executeInTransaction( txn ->
|
|
@@ -165,6 +180,15 @@ public class XodusLocalDB implements LocalDBProvider
|
|
|
if ( environment != null && environment.isOpen() )
|
|
|
{
|
|
|
environment.close();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ Files.deleteIfExists( getDirtyFile().toPath() );
|
|
|
+ LOGGER.trace( () -> "deleted openLock file" );
|
|
|
+ }
|
|
|
+ catch ( IOException e )
|
|
|
+ {
|
|
|
+ LOGGER.error( "error creating openLock file: " + e.getMessage() );
|
|
|
+ }
|
|
|
}
|
|
|
status = LocalDB.Status.CLOSED;
|
|
|
LOGGER.debug( () -> "closed" );
|
|
@@ -176,7 +200,16 @@ public class XodusLocalDB implements LocalDBProvider
|
|
|
environmentConfig.setEnvCloseForcedly( true );
|
|
|
environmentConfig.setMemoryUsage( 50 * 1024 * 1024 );
|
|
|
environmentConfig.setEnvGatherStatistics( true );
|
|
|
- environmentConfig.setGcUtilizationFromScratch( true );
|
|
|
+
|
|
|
+ if ( Files.exists( getDirtyFile().toPath() ) )
|
|
|
+ {
|
|
|
+ environmentConfig.setGcUtilizationFromScratch( true );
|
|
|
+ LOGGER.warn( "environment not closed cleanly, will re-calculate GC" );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LOGGER.debug( () -> "environment was closed cleanly" );
|
|
|
+ }
|
|
|
|
|
|
for ( final Map.Entry<String, String> entry : initParameters.entrySet() )
|
|
|
{
|
|
@@ -628,4 +661,9 @@ public class XodusLocalDB implements LocalDBProvider
|
|
|
LOGGER.error( "error writing LocalDB readme file: " + e.getMessage() );
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private File getDirtyFile()
|
|
|
+ {
|
|
|
+ return new File( this.getFileLocation().getAbsolutePath() + File.separator + FILE_SUB_PATH + File.separator + "xodus.open" );
|
|
|
+ }
|
|
|
}
|