Skip to content

Commit

Permalink
Merge pull request #9811 from tinwelint/3.3-apply-label-and-index-par…
Browse files Browse the repository at this point in the history
…allel

Applies label and index updates in parallel
  • Loading branch information
tinwelint committed Aug 24, 2017
2 parents ec45bb4 + 69244d4 commit 16b8e4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.concurrent.ExecutionException;
import java.util.function.Supplier;

import org.neo4j.concurrent.AsyncApply;
import org.neo4j.concurrent.WorkSync;
import org.neo4j.kernel.api.exceptions.index.IndexActivationFailedKernelException;
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
Expand Down Expand Up @@ -87,31 +88,37 @@ public TransactionApplier startTx( CommandsToApply transaction )

private void applyPendingLabelAndIndexUpdates() throws IOException
{
AsyncApply labelUpdatesApply = null;
if ( labelUpdates != null )
{
// Updates are sorted according to node id here, an artifact of node commands being sorted
// by node id when extracting from TransactionRecordState.
labelUpdatesApply = labelScanStoreSync.applyAsync( new LabelUpdateWork( labelUpdates ) );
labelUpdates = null;
}
if ( indexUpdates != null && indexUpdates.hasUpdates() )
{
try
{
labelScanStoreSync.apply( new LabelUpdateWork( labelUpdates ) );
indexUpdatesSync.apply( new IndexUpdatesWork( indexUpdates ) );
}
catch ( ExecutionException e )
{
throw new IOException( "Failed to flush label updates", e );
throw new IOException( "Failed to flush index updates", e );
}
labelUpdates = null;
indexUpdates = null;
}
if ( indexUpdates != null && indexUpdates.hasUpdates() )

if ( labelUpdatesApply != null )
{
try
{
indexUpdatesSync.apply( new IndexUpdatesWork( indexUpdates ) );
labelUpdatesApply.await();
}
catch ( ExecutionException e )
{
throw new IOException( "Failed to flush index updates", e );
throw new IOException( "Failed to flush label updates", e );
}
indexUpdates = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ indexUpdatesSync, mock( NodeStore.class ),
}
}
// THEN all assertions happen inside the LabelScanWriter#write and #close
verify( labelScanSync ).apply( any() );
verify( labelScanSync ).applyAsync( any() );
}

private Supplier<LabelScanWriter> singletonProvider( final LabelScanWriter writer )
Expand Down

0 comments on commit 16b8e4a

Please sign in to comment.