Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Executes schema rule commands after producing property updates to gua…

…rd for a scenario outlined in the comments
  • Loading branch information...
commit b0e39b4ad1e59f277067bd92dc91c5d21db4f110 1 parent 01b4bba
@tinwelint tinwelint authored
View
35 community/kernel/src/main/java/org/neo4j/kernel/impl/nioneo/xa/WriteTransaction.java
@@ -605,19 +605,6 @@ private void applyCommit( boolean isRecovered )
}
}
}
- // schema rules
- for ( SchemaRuleCommand command : schemaRuleCommands )
- {
- command.execute();
- switch ( command.getMode() )
- {
- case DELETE:
- cacheAccess.removeSchemaRuleFromCache( command.getKey() );
- break;
- default:
- cacheAccess.addSchemaRule( command.getSchemaRule() );
- }
- }
// primitives
// java.util.Collections.sort( nodeCommands, sorter ); // it's a TreeMap so already sorted.
@@ -631,6 +618,28 @@ private void applyCommit( boolean isRecovered )
Iterable<NodePropertyUpdate> updates = convertIntoLogicalPropertyUpdates();
indexes.updateIndexes( updates );
+ // schema rules. Execute these after generating the property updates so. If executed
+ // before and we've got a transaction that sets properties/labels as well as creating an index
+ // we might end up with this corner-case:
+ // 1) index rule created and index population job started
+ // 2) index population job processes some nodes, but doesn't complete
+ // 3) we gather up property updates and send those to the indexes. The newly created population
+ // job might get those as updates
+ // 4) the population job will apply those updates as added properties, and might end up with duplicate
+ // entries for the same property
+ for ( SchemaRuleCommand command : schemaRuleCommands )
+ {
+ command.execute();
+ switch ( command.getMode() )
+ {
+ case DELETE:
+ cacheAccess.removeSchemaRuleFromCache( command.getKey() );
+ break;
+ default:
+ cacheAccess.addSchemaRule( command.getSchemaRule() );
+ }
+ }
+
if ( neoStoreCommand != null )
{
neoStoreCommand.execute();
Please sign in to comment.
Something went wrong with that request. Please try again.