@Test public void checkingIfRecordIsInUseMustHappenAfterConsistentRead() { AtomicBoolean nextReadIsInconsistent = new AtomicBoolean( false ); PageCache pageCache = pageCacheRule.getPageCache( fs, config().withInconsistentReads( nextReadIsInconsistent ) ); StoreFactory factory = factory( null, pageCache ); try ( NeoStores neoStores = factory.openAllNeoStores( true ) ) { RecordStore<RelationshipGroupRecord> relationshipGroupStore = neoStores.getRelationshipGroupStore(); RelationshipGroupRecord record = new RelationshipGroupRecord( 1 ).initialize( true, 2, 3, 4, 5, 6, Record.NO_NEXT_RELATIONSHIP.intValue() ); relationshipGroupStore.updateRecord( record ); nextReadIsInconsistent.set( true ); // Now the following should not throw any RecordNotInUse exceptions RelationshipGroupRecord readBack = relationshipGroupStore.getRecord( 1, relationshipGroupStore.newRecord(), NORMAL ); assertThat( readBack.toString(), equalTo( record.toString() ) ); } }
private NeoStores storeFixture() { PageCache pageCache = pageCacheRule.getPageCache( fs, config().withInconsistentReads( nextReadIsInconsistent ) ); StoreFactory factory = new StoreFactory( testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory( fs ), pageCache, fs, NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); NeoStores neoStores = factory.openAllNeoStores( true ); S store = initialiseStore( neoStores ); CommonAbstractStore commonAbstractStore = (CommonAbstractStore) store; commonAbstractStore.rebuildIdGenerator(); return neoStores; }