Skip to content

Commit

Permalink
Set store high id in end instead of apply in HighIdTransactionApp…
Browse files Browse the repository at this point in the history
…lier

Problem was that the se high id was set in `apply` (which is now
called at the end of a tx application batch) and the data applied
wasn't effectively available to transactions applied in the same
batch. E.g., populating an index (created in the same batch) would
have missed all the new nodes added by transactions preciding it in
the batch.
  • Loading branch information
davidegrohmann authored and tinwelint committed Dec 4, 2015
1 parent c1c7ccb commit 17da93c
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 82 deletions.
Expand Up @@ -135,9 +135,9 @@ public boolean visitSchemaRuleCommand( SchemaRuleCommand command ) throws IOExce
} }


@Override @Override
public void apply() public void end() throws Exception
{ {
super.apply(); super.end();
// Notifies the stores about the recovered ids and will bump those high ids atomically if // Notifies the stores about the recovered ids and will bump those high ids atomically if
// they surpass the current high ids // they surpass the current high ids
for ( Map.Entry<CommonAbstractStore,HighId> highId : highIds.entrySet() ) for ( Map.Entry<CommonAbstractStore,HighId> highId : highIds.entrySet() )
Expand Down
Expand Up @@ -22,12 +22,14 @@
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;


import org.neo4j.kernel.impl.api.TransactionToApply;
import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.NeoStores;
import org.neo4j.kernel.impl.store.PropertyType; import org.neo4j.kernel.impl.store.PropertyType;
import org.neo4j.test.NeoStoresRule; import org.neo4j.test.NeoStoresRule;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;


import static org.mockito.Mockito.mock;
import static org.neo4j.kernel.impl.transaction.command.CommandHandler.EMPTY; import static org.neo4j.kernel.impl.transaction.command.CommandHandler.EMPTY;


public class HighIdTransactionApplierTest public class HighIdTransactionApplierTest
Expand All @@ -42,6 +44,7 @@ public void shouldUpdateHighIdsOnExternalTransaction() throws Exception
NeoStores neoStores = neoStoresRule.open(); NeoStores neoStores = neoStoresRule.open();
HighIdTransactionApplier tracker = new HighIdTransactionApplier( EMPTY, neoStores ); HighIdTransactionApplier tracker = new HighIdTransactionApplier( EMPTY, neoStores );


tracker.begin( mock( TransactionToApply.class ) );
// WHEN // WHEN
// Nodes // Nodes
tracker.visitNodeCommand( Commands.createNode( 10, 2, 3 ) ); tracker.visitNodeCommand( Commands.createNode( 10, 2, 3 ) );
Expand Down Expand Up @@ -75,6 +78,8 @@ public void shouldUpdateHighIdsOnExternalTransaction() throws Exception
tracker.visitPropertyCommand( Commands.createProperty( 10, PropertyType.STRING, 0, 6, 7 ) ); tracker.visitPropertyCommand( Commands.createProperty( 10, PropertyType.STRING, 0, 6, 7 ) );
tracker.visitPropertyCommand( Commands.createProperty( 20, PropertyType.ARRAY, 1, 8, 9 ) ); tracker.visitPropertyCommand( Commands.createProperty( 20, PropertyType.ARRAY, 1, 8, 9 ) );


tracker.end();

tracker.apply(); tracker.apply();
tracker.close(); tracker.close();


Expand Down

0 comments on commit 17da93c

Please sign in to comment.