public GraphDatabaseAPI restartDatabase( String... configChanges ) throws IOException { return restartDatabase( RestartAction.EMPTY, configChanges ); }
private void forceRecover() throws IOException { db.restartDatabase(); }
void applySetting( Setting<String> setting, String value ) throws IOException { db.restartDatabase( setting.name(), value ); db.ensureStarted(); fulltextAdapter = getAccessor(); }
@Test public void createAndRetainFulltextIndex() throws Exception { IndexReference fulltextIndex = createIndex( new int[]{7, 8, 9}, new int[]{2, 3, 4} ); db.restartDatabase( DatabaseRule.RestartAction.EMPTY ); verifyThatFulltextIndexIsPresent( fulltextIndex ); }
@Test public void createAndRetainRelationshipFulltextIndex() throws Exception { IndexReference indexReference; try ( KernelTransactionImplementation transaction = getKernelTransaction() ) { MultiTokenSchemaDescriptor multiTokenSchemaDescriptor = multiToken( new int[]{0, 1, 2}, EntityType.RELATIONSHIP, 0, 1, 2, 3 ); FulltextSchemaDescriptor schema = new FulltextSchemaDescriptor( multiTokenSchemaDescriptor, new Properties() ); indexReference = transaction.schemaWrite().indexCreate( schema, DESCRIPTOR.name(), Optional.of( "fulltext" ) ); transaction.success(); } await( indexReference ); db.restartDatabase( DatabaseRule.RestartAction.EMPTY ); verifyThatFulltextIndexIsPresent( indexReference ); }
@Test public void rebuildCorruptedLabelScanStoreToStartup() throws Exception { Node node = createLabeledNode( Labels.First ); dbRule.restartDatabase( corruptTheLabelScanStoreIndex() ); assertEquals( asSet( node ), getAllNodesWithLabel( Labels.First ) ); }
@Test public void shouldRebuildDeletedLabelScanStoreOnStartup() throws Exception { // GIVEN Node node1 = createLabeledNode( Labels.First ); Node node2 = createLabeledNode( Labels.First ); Node node3 = createLabeledNode( Labels.First ); deleteNode( node2 ); // just to create a hole in the store // WHEN dbRule.restartDatabase( deleteTheLabelScanStoreIndex() ); // THEN assertEquals( asSet( node1, node3 ), getAllNodesWithLabel( Labels.First ) ); }
@Test public void createAndQueryFulltextIndex() throws Exception { IndexReference indexReference; FulltextIndexProvider provider = (FulltextIndexProvider) db.resolveDependency( IndexProviderMap.class ).lookup( DESCRIPTOR ); indexReference = createIndex( new int[]{0, 1, 2}, new int[]{0, 1, 2, 3} ); await( indexReference ); long thirdNodeid; thirdNodeid = createTheThirdNode(); verifyNodeData( provider, thirdNodeid ); db.restartDatabase( DatabaseRule.RestartAction.EMPTY ); provider = (FulltextIndexProvider) db.resolveDependency( IndexProviderMap.class ).lookup( DESCRIPTOR ); verifyNodeData( provider, thirdNodeid ); }
@Test public void shouldNotBeAbleToViolateConstraintWhenBackingIndexFailsToOpen() throws Exception { // given try ( Transaction tx = db.beginTx() ) { db.schema().constraintFor( PERSON ).assertPropertyIsUnique( "name" ).create(); tx.success(); } createNamed( PERSON, "Lars" ); // when - we restart the database in a state where the index is not operational db.restartDatabase( new SabotageNativeIndex( random.random() ) ); // then - we must not be able to violate the constraint createNamed( PERSON, "Johan" ); Throwable failure = null; try { createNamed( PERSON, "Lars" ); } catch ( Throwable e ) { // this must fail, otherwise we have violated the constraint failure = e; } assertNotNull( failure ); indexStateShouldBe( equalTo( ONLINE ) ); }
@Test public void createAndQueryFulltextRelationshipIndex() throws Exception { FulltextIndexProvider provider = (FulltextIndexProvider) db.resolveDependency( IndexProviderMap.class ).lookup( DESCRIPTOR ); IndexReference indexReference; try ( KernelTransactionImplementation transaction = getKernelTransaction() ) { MultiTokenSchemaDescriptor multiTokenSchemaDescriptor = multiToken( new int[]{0, 1, 2}, EntityType.RELATIONSHIP, 0, 1, 2, 3 ); FulltextSchemaDescriptor schema = new FulltextSchemaDescriptor( multiTokenSchemaDescriptor, new Properties() ); indexReference = transaction.schemaWrite().indexCreate( schema, DESCRIPTOR.name(), Optional.of( "fulltext" ) ); transaction.success(); } await( indexReference ); long secondRelId; try ( Transaction transaction = db.beginTx() ) { Relationship ho = node1.createRelationshipTo( node2, RelationshipType.withName( "ho" ) ); secondRelId = ho.getId(); ho.setProperty( "hej", "villa" ); ho.setProperty( "ho", "value3" ); transaction.success(); } verifyRelationshipData( provider, secondRelId ); db.restartDatabase( DatabaseRule.RestartAction.EMPTY ); provider = (FulltextIndexProvider) db.resolveDependency( IndexProviderMap.class ).lookup( DESCRIPTOR ); verifyRelationshipData( provider, secondRelId ); }
@Test public void failedIndexShouldRepairAutomatically() throws Exception { // given try ( Transaction tx = db.beginTx() ) { db.schema().indexFor( PERSON ).on( "name" ).create(); tx.success(); } awaitIndexesOnline( 5, SECONDS ); createNamed( PERSON, "Johan" ); // when - we restart the database in a state where the index is not operational db.restartDatabase( new SabotageNativeIndex( random.random() ) ); // then - the database should still be operational createNamed( PERSON, "Lars" ); awaitIndexesOnline( 5, SECONDS ); indexStateShouldBe( equalTo( ONLINE ) ); assertFindsNamed( PERSON, "Lars" ); }
db.restartDatabase( GraphDatabaseSettings.read_only.name(), TRUE.toString() ); try ( Transaction tx = db.beginTx() )
@Test public void shouldReuseExcessBatchIdsWhichWerentUsedBeforeClose() throws Exception { // given Node firstNode; try ( Transaction tx = db.beginTx() ) { firstNode = db.createNode(); tx.success(); } // when db.restartDatabase(); Node secondNode; try ( Transaction tx = db.beginTx() ) { secondNode = db.createNode(); tx.success(); } // then assertEquals( firstNode.getId() + 1, secondNode.getId() ); } }
@Test public void shouldArchiveFailedIndex() throws Exception { // given db.withSetting( GraphDatabaseSettings.archive_failed_index, "true" ); try ( Transaction tx = db.beginTx() ) { Node node = db.createNode( PERSON ); node.setProperty( "name", "Fry" ); tx.success(); } try ( Transaction tx = db.beginTx() ) { Node node = db.createNode( PERSON ); node.setProperty( "name", Values.pointValue( CoordinateReferenceSystem.WGS84, 1, 2 ) ); tx.success(); } try ( Transaction tx = db.beginTx() ) { db.schema().constraintFor( PERSON ).assertPropertyIsUnique( "name" ).create(); tx.success(); } assertThat( archiveFile(), nullValue() ); // when db.restartDatabase( new SabotageNativeIndex( random.random() ) ); // then indexStateShouldBe( equalTo( ONLINE ) ); assertThat( archiveFile(), notNullValue() ); }
public GraphDatabaseAPI restartDatabase( String... configChanges ) throws IOException { return restartDatabase( RestartAction.EMPTY, configChanges ); }