-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5935 from maxsumrall/2.2-slave-replanning
Fixed issue with last committed tx id in query planning
- Loading branch information
Showing
16 changed files
with
477 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ty/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/LastCommittedTxIdProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2002-2015 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.cypher.internal | ||
|
||
import org.neo4j.graphdb.GraphDatabaseService | ||
import org.neo4j.kernel.GraphDatabaseAPI | ||
import org.neo4j.kernel.impl.transaction.log.TransactionIdStore | ||
|
||
case class LastCommittedTxIdProvider(db: GraphDatabaseService) extends (() => Long) { | ||
|
||
private val resolver = db.asInstanceOf[GraphDatabaseAPI].getDependencyResolver | ||
|
||
override def apply(): Long = { | ||
val txIdStore = resolver.resolveDependency(classOf[TransactionIdStore]) | ||
txIdStore.getLastCommittedTransactionId | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...ypher/cypher/src/test/scala/org/neo4j/cypher/internal/LastCommittedTxIdProviderTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2002-2015 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.cypher.internal | ||
|
||
import org.neo4j.cypher.internal.commons.CypherFunSuite | ||
import org.neo4j.kernel.NeoStoreDataSource | ||
import org.neo4j.test.ImpermanentGraphDatabase | ||
import org.scalatest.BeforeAndAfterAll | ||
|
||
class LastCommittedTxIdProviderTest extends CypherFunSuite with BeforeAndAfterAll { | ||
|
||
var db: ImpermanentGraphDatabase = null | ||
var lastCommittedTxIdProvider: LastCommittedTxIdProvider = null | ||
|
||
override protected def beforeAll(): Unit = { | ||
db = new ImpermanentGraphDatabase() | ||
lastCommittedTxIdProvider = LastCommittedTxIdProvider(db) | ||
} | ||
|
||
override protected def afterAll(): Unit = db.shutdown() | ||
|
||
test("should return correct last committed tx id") { | ||
val startingTxId = lastCommittedTxIdProvider() | ||
|
||
(1 to 42).foreach(_ => createNode()) | ||
|
||
val endingTxId = lastCommittedTxIdProvider() | ||
endingTxId shouldBe (startingTxId + 42) | ||
} | ||
|
||
test("should return correct last committed tx id after datasource restart") { | ||
val startingTxId = lastCommittedTxIdProvider() | ||
|
||
restartDataSource() | ||
(1 to 42).foreach(_ => createNode()) | ||
|
||
val endingTxId = lastCommittedTxIdProvider() | ||
endingTxId shouldBe (startingTxId + 42) | ||
} | ||
|
||
private def createNode(): Unit = { | ||
val tx = db.beginTx() | ||
try { | ||
db.createNode() | ||
tx.success() | ||
} | ||
finally { | ||
tx.close() | ||
} | ||
} | ||
|
||
private def restartDataSource(): Unit = { | ||
val ds = db.getDependencyResolver.resolveDependency(classOf[NeoStoreDataSource]) | ||
ds.stop() | ||
ds.start() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.