Skip to content

Commit

Permalink
Using a separate redis connection to read keys when removing an index
Browse files Browse the repository at this point in the history
  • Loading branch information
tareqabedrabbo committed Apr 28, 2011
1 parent 60f7779 commit 366448f
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/main/java/org/neo4j/index/redis/RedisTransaction.java
Expand Up @@ -21,6 +21,7 @@


import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Set;


import javax.transaction.xa.XAException; import javax.transaction.xa.XAException;


Expand Down Expand Up @@ -91,15 +92,25 @@ else if ( kvCommand instanceof KeyValueCommand.RemoveCommand )
// For future deletion of the index // For future deletion of the index
transaction.srem( indexName, redisKey ); transaction.srem( indexName, redisKey );
} }
// else if ( kvCommand instanceof KeyValueCommand.DeleteIndexCommand ) else if ( kvCommand instanceof KeyValueCommand.DeleteIndexCommand ) {
// { // TODO this doesn't really scale... getting all the keys for an
// // TODO this doesn't really scale... getting all the keys for an // index can potentially eat up the entire heap. Consider replacing with a list.
// // index can potentially eat up the entire heap.
// for ( String indexKey : redisResource.smembers( indexName ) ) // acquire a separate redis connection to read the all the index keys.
// { // using the current redisResource is not possible because of the ongoing transaction
// transaction.del( indexKey ); Jedis readOnlyRedisResource = null;
// } Set<String> members;
// } try {
readOnlyRedisResource = getDataSource().acquireResource();
members = readOnlyRedisResource.smembers(indexName);
} finally {
getDataSource().releaseResource(readOnlyRedisResource);
}

for (String indexKey : members) {
transaction.del(indexKey);
}
}
} }
} }
closeTxData(); closeTxData();
Expand Down

0 comments on commit 366448f

Please sign in to comment.