Permalink
Browse files

To solve a issue that will return a null if a concurrent read is being

done in the middle of a write of same entry.
  • Loading branch information...
1 parent e6abad1 commit cccb8c3dab15bc9a0b3ca1cfab2fbe4551a71ad7 @zhongjiewu zhongjiewu committed May 24, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/java/voldemort/store/bdb/BdbStorageEngine.java
@@ -212,7 +212,15 @@ private boolean reopenBdbDatabase() {
Cursor cursor = null;
try {
cursor = getBdbDatabase().openCursor(null, null);
- return get(cursor, key, lockMode, serializer);
+ List<T> result = get(cursor, key, lockMode, serializer);
+
+ // If null, try again in different locking mode to
+ // avoid null result due to gap between delete and new write
+ if(result.size() == 0 && lockMode != LockMode.DEFAULT) {
+ return get(cursor, key, LockMode.DEFAULT, serializer);
+ } else {
+ return result;
+ }
} catch(DatabaseException e) {
logger.error(e);
throw new PersistenceFailureException(e);

0 comments on commit cccb8c3

Please sign in to comment.