Neo4j嵌入了Java的在线备份

时间:2013-11-25 07:28:41

标签: scala neo4j database-backups graph-databases

我在项目中使用Neo4j(嵌入式)企业版1.9.4以及Scala-Neo4j包装器。我尝试使用Java备份Neo4j数据,如下所示

  def backup_data()
  {
        val backupPath: File = new File("D:/neo4j-enterprise-1.9.4/data/backup/")
        val backup = OnlineBackup.from( "127.0.0.1" )
        if(backupPath.list().length > 0)
        {
            backup.incremental( backupPath.getPath() )
        }
        else
        {
        backup.full( backupPath.getPath() );
        }
  }

完全备份工作正常。但增量备份部分抛出了Null指针异常。

我哪里出错了?

修改

通过Scala-Neo4j包装器构建GraphDatabase实例

class MyNeo4jClass extends SomethingClass with Neo4jWrapper with EmbeddedGraphDatabaseServiceProvider {
  def neo4jStoreDir = "/tmp/temp-neo-test"
  . . .
}

堆栈跟踪

Exception in thread "main" java.lang.NullPointerException
    at org.neo4j.consistency.checking.OwnerChain$3.checkReference(OwnerChain.java:111)
    at org.neo4j.consistency.checking.OwnerChain$3.checkReference(OwnerChain.java:106)
    at org.neo4j.consistency.report.ConsistencyReporter$DiffReportHandler.checkReference(ConsistencyReporter.java:330)
    at org.neo4j.consistency.report.ConsistencyReporter.dispatchReference(ConsistencyReporter.java:109)
    at org.neo4j.consistency.report.PendingReferenceCheck.checkReference(PendingReferenceCheck.java:50)
    at org.neo4j.consistency.store.DirectRecordReference.dispatch(DirectRecordReference.java:39)
    at org.neo4j.consistency.report.ConsistencyReporter$ReportInvocationHandler.forReference(ConsistencyReporter.java:236)
    at org.neo4j.consistency.report.ConsistencyReporter$ReportInvocationHandler.dispatchForReference(ConsistencyReporter.java:228)
    at org.neo4j.consistency.report.ConsistencyReporter$ReportInvocationHandler.invoke(ConsistencyReporter.java:192)
    at $Proxy17.forReference(Unknown Source)
    at org.neo4j.consistency.checking.OwnerChain.check(OwnerChain.java:143)
    at org.neo4j.consistency.checking.PropertyRecordCheck.checkChange(PropertyRecordCheck.java:57)
    at org.neo4j.consistency.checking.PropertyRecordCheck.checkChange(PropertyRecordCheck.java:35)
    at org.neo4j.consistency.report.ConsistencyReporter.dispatchChange(ConsistencyReporter.java:101)
    at org.neo4j.consistency.report.ConsistencyReporter.forPropertyChange(ConsistencyReporter.java:382)
    at org.neo4j.consistency.checking.incremental.StoreProcessor.checkProperty(StoreProcessor.java:61)
    at org.neo4j.consistency.checking.AbstractStoreProcessor.processProperty(AbstractStoreProcessor.java:95)
    at org.neo4j.consistency.store.DiffRecordStore$DispatchProcessor.processProperty(DiffRecordStore.java:207)
    at org.neo4j.kernel.impl.nioneo.store.PropertyStore.accept(PropertyStore.java:83)
    at org.neo4j.kernel.impl.nioneo.store.PropertyStore.accept(PropertyStore.java:43)
    at org.neo4j.consistency.store.DiffRecordStore.accept(DiffRecordStore.java:159)
    at org.neo4j.kernel.impl.nioneo.store.RecordStore$Processor.applyById(RecordStore.java:180)
    at org.neo4j.consistency.store.DiffStore.apply(DiffStore.java:73)
    at org.neo4j.kernel.impl.nioneo.store.StoreAccess.applyToAll(StoreAccess.java:174)
    at org.neo4j.consistency.checking.incremental.IncrementalDiffCheck.execute(IncrementalDiffCheck.java:43)
    at org.neo4j.consistency.checking.incremental.DiffCheck.check(DiffCheck.java:39)
    at org.neo4j.consistency.checking.incremental.intercept.CheckingTransactionInterceptor.complete(CheckingTransactionInterceptor.java:160)
    at org.neo4j.kernel.impl.transaction.xaframework.InterceptingXaLogicalLog$1.intercept(InterceptingXaLogicalLog.java:79)
    at org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog$LogDeserializer.readAndWriteAndApplyEntry(XaLogicalLog.java:1120)
    at org.neo4j.kernel.impl.transaction.xaframework.XaLogicalLog.applyTransaction(XaLogicalLog.java:1292)
    at org.neo4j.kernel.impl.transaction.xaframework.XaResourceManager.applyCommittedTransaction(XaResourceManager.java:766)
    at org.neo4j.kernel.impl.transaction.xaframework.XaDataSource.applyCommittedTransaction(XaDataSource.java:246)
    at org.neo4j.com.ServerUtil.applyReceivedTransactions(ServerUtil.java:423)
    at org.neo4j.backup.BackupService.unpackResponse(BackupService.java:453)
    at org.neo4j.backup.BackupService.incrementalWithContext(BackupService.java:388)
    at org.neo4j.backup.BackupService.doIncrementalBackup(BackupService.java:286)
    at org.neo4j.backup.BackupService.doIncrementalBackup(BackupService.java:273)
    at org.neo4j.backup.OnlineBackup.incremental(OnlineBackup.java:147)
    at Saddahaq.User_node$.backup_data(User_node.scala:1637)
    at Saddahaq.User_node$.main(User_node.scala:2461)
    at Saddahaq.User_node.main(User_node.scala)

1 个答案:

答案 0 :(得分:2)

进行备份后,将检查支持的目标的一致性。一致性检查程序的增量版本目前存在导致观察到的NPE的错误。

解决方法:要么始终使用backup.full进行完整备份,要么使用

阻止对增量备份进行一致性检查
backup.incremental(backupPath.getPath(), false);