diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/BackupFlow.java b/enterprise/backup/src/main/java/org/neo4j/backup/BackupFlow.java index 4071c87381702..2cbee4a547428 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/BackupFlow.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/BackupFlow.java @@ -20,7 +20,6 @@ package org.neo4j.backup; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.function.Supplier; @@ -30,10 +29,7 @@ import org.neo4j.consistency.ConsistencyCheckService; import org.neo4j.consistency.checking.full.ConsistencyFlags; import org.neo4j.helpers.progress.ProgressMonitorFactory; -import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.configuration.Config; -import org.neo4j.kernel.impl.transaction.log.files.LogFiles; -import org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder; import org.neo4j.logging.LogProvider; import static java.lang.String.format; @@ -104,30 +100,6 @@ void performBackup( OnlineBackupContext onlineBackupContext ) throws CommandFail { performConsistencyCheck( onlineBackupContext.getConfig(), requiredArgs, consistencyFlags, destination ); } - cleanupTransactionLogFiles( destination ); - } - - /** - * As result of backup database should be fully restored and it should be safe to delete any transaction log - * files that available since they also can be configured to live in a separate place on the instance where db - * will be restored. - * @param backupFolder backup folder - */ - private void cleanupTransactionLogFiles( File backupFolder ) throws CommandFailed - { - try - { - FileSystemAbstraction fileSystem = outsideWorld.fileSystem(); - LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( backupFolder, fileSystem ).build(); - for ( File file : logFiles.logFiles() ) - { - fileSystem.deleteFile( file ); - } - } - catch ( IOException e ) - { - throw new CommandFailed( format( "Fail to cleanup transaction logs." ), e ); - } } private static Supplier commandFailedWithCause( PotentiallyErroneousState cause ) diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/BackupProtocolService.java b/enterprise/backup/src/main/java/org/neo4j/backup/BackupProtocolService.java index f41ad3226a9c9..efed81c97acae 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/BackupProtocolService.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/BackupProtocolService.java @@ -66,8 +66,6 @@ import org.neo4j.kernel.impl.transaction.log.MissingLogDataException; import org.neo4j.kernel.impl.transaction.log.TransactionIdStore; import org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader; -import org.neo4j.kernel.impl.transaction.log.files.LogFiles; -import org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.kernel.lifecycle.Lifespan; import org.neo4j.kernel.monitoring.ByteCounterMonitor; @@ -166,7 +164,6 @@ private BackupOutcome fullBackup( FileSystemAbstraction fileSystem, String sourc bumpDebugDotLogFileVersion( debugLogFile, timestamp ); boolean consistent = checkDbConsistency( fileSystem, targetDirectory, consistencyCheck, tuningConfiguration, pageCache ); clearIdFiles( fileSystem, targetDirectory ); - clearTransactionLogFiles( fileSystem, targetDirectory ); return new BackupOutcome( lastCommittedTx, consistent ); } catch ( Exception e ) @@ -221,7 +218,6 @@ private BackupOutcome incrementalBackup( FileSystemAbstraction fileSystem, Strin bumpDebugDotLogFileVersion( debugLogFile, backupStartTime ); boolean consistent = checkDbConsistency( fileSystem, targetDirectory, consistencyCheck, config, pageCache ); clearIdFiles( fileSystem, targetDirectory ); - clearTransactionLogFiles( fileSystem, targetDirectory ); return new BackupOutcome( lastCommittedTx, consistent ); } catch ( IOException e ) @@ -418,17 +414,6 @@ private List> loadKernelExtensions() return kernelExtensions; } - private void clearTransactionLogFiles( FileSystemAbstraction fileSystem, File targetDirectory ) throws IOException - { - LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( targetDirectory, fileSystem ).build(); - File[] files = logFiles.logFiles(); - for ( File file : files ) - { - fileSystem.deleteFile( file ); - } - - } - private void clearIdFiles( FileSystemAbstraction fileSystem, File targetDirectory ) throws IOException { for ( File file : fileSystem.listFiles( targetDirectory ) ) diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/BackupIT.java b/enterprise/backup/src/test/java/org/neo4j/backup/BackupIT.java index 40cc20b16cc35..7b0281236dac4 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/BackupIT.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/BackupIT.java @@ -510,11 +510,11 @@ public void backupDatabaseWithCustomTransactionLogsLocation() throws IOException LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( new File( backupStore ), fileSystemRule.get() ).build(); backup.full( backupStore ); - assertThat( logFiles.logFiles(), Matchers.emptyArray() ); + assertThat( logFiles.logFiles(), Matchers.arrayWithSize( 1 ) ); DbRepresentation representation = addLotsOfData( db ); backup.incremental( backupStore ); - assertThat( logFiles.logFiles(), Matchers.emptyArray() ); + assertThat( logFiles.logFiles(), Matchers.arrayWithSize( 1 ) ); assertEquals( representation, getDbRepresentation() ); } diff --git a/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupCoreIT.java b/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupCoreIT.java index 0a648e676cb54..c755f095411a7 100644 --- a/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupCoreIT.java +++ b/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupCoreIT.java @@ -24,7 +24,6 @@ import org.junit.Test; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -36,19 +35,15 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.helpers.collection.MapUtil; -import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.enterprise.configuration.OnlineBackupSettings; import org.neo4j.kernel.impl.store.format.standard.Standard; -import org.neo4j.kernel.impl.transaction.log.files.LogFiles; -import org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder; import org.neo4j.ports.allocation.PortAuthority; import org.neo4j.test.DbRepresentation; import org.neo4j.test.causalclustering.ClusterRule; import org.neo4j.test.rule.SuppressOutput; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.neo4j.graphdb.Label.label; import static org.neo4j.util.TestHelpers.runBackupToolFromOtherJvmToGetExitCode; @@ -82,8 +77,6 @@ public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable String[] args = backupArguments( backupAddress( cluster ), backupsDir, "" + db.serverId() ); assertEquals( 0, runBackupToolFromOtherJvmToGetExitCode( clusterRule.clusterDirectory(), args ) ); - checkThatTxLogFilesDoesNotExist( db ); - // Add some new data DbRepresentation afterChange = DbRepresentation.of( createSomeData( cluster ) ); @@ -94,14 +87,6 @@ public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable } } - private void checkThatTxLogFilesDoesNotExist( CoreClusterMember db ) throws IOException - { - FileSystemAbstraction fileSystemAbstraction = - db.database().getDependencyResolver().resolveDependency( FileSystemAbstraction.class ); - LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( backupsDir, fileSystemAbstraction ).build(); - assertFalse( logFiles.versionExists( 0 ) ); - } - static CoreGraphDatabase createSomeData( Cluster cluster ) throws Exception { return cluster.coreTx( ( db, tx ) -> diff --git a/tools/src/main/java/org/neo4j/tools/applytx/ApplyTransactionsCommand.java b/tools/src/main/java/org/neo4j/tools/applytx/ApplyTransactionsCommand.java index ed38ba4d55868..b1732d3837347 100644 --- a/tools/src/main/java/org/neo4j/tools/applytx/ApplyTransactionsCommand.java +++ b/tools/src/main/java/org/neo4j/tools/applytx/ApplyTransactionsCommand.java @@ -95,7 +95,7 @@ else if ( whereTo.equals( "last" ) ) out.println( "Applied transactions up to and including " + lastApplied ); } - private long applyTransactions( File fromPath, GraphDatabaseAPI toDb, Config config, + private long applyTransactions( File fromPath, GraphDatabaseAPI toDb, Config toConfig, long fromTxExclusive, long toTxInclusive, PrintStream out ) throws IOException, TransactionFailureException { @@ -109,7 +109,7 @@ private long applyTransactions( File fromPath, GraphDatabaseAPI toDb, Config con PageCache pageCache = StandalonePageCacheFactory.createPageCache( fileSystem ) ) { LogicalTransactionStore source = life.add( new ReadOnlyTransactionStore( pageCache, fileSystem, fromPath, - config, new Monitors() ) ); + Config.defaults(), new Monitors() ) ); life.start(); long lastAppliedTx = fromTxExclusive; // Some progress if there are more than a couple of transactions to apply