summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo/indexed
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2008-09-08 21:05:00 +0000
committerBrian S. O'Neill <bronee@gmail.com>2008-09-08 21:05:00 +0000
commit78d46cef0dd3d9a5051a4b60b755244b5077859d (patch)
tree85c28efb965e63e5bad553b126f2b9c96407b1a2 /src/main/java/com/amazon/carbonado/repo/indexed
parent3866b2d9b6082f618daf04bfe5d954a3f8e66af2 (diff)
Index truncation is no longer in transaction with primary records to avoid deadlock.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/indexed')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java
index 1abb064..6b2fed9 100644
--- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedStorage.java
@@ -142,20 +142,20 @@ class IndexedStorage<S extends Storable> implements Storage<S>, StorageAccess<S>
return;
}
- Transaction txn = mRepository.enterTransaction();
- try {
- mMasterStorage.truncate();
-
- // Now truncate the indexes.
- for (IndexInfo info : mAllIndexInfoMap.values()) {
- if (info instanceof ManagedIndex) {
- ((ManagedIndex) info).getIndexEntryStorage().truncate();
- }
+ // Although the master storage and indexes should be truncated
+ // atomically, this cannot be guaranteed due to freedom of truncate
+ // implementation. Also, a transaction can be deadlock prone with
+ // concurrent queries and updates. Instead, truncate the master first,
+ // which may cause warnings to be logged if index entries refer to
+ // missing records. This is harmless.
+
+ mMasterStorage.truncate();
+
+ // Now truncate the indexes.
+ for (IndexInfo info : mAllIndexInfoMap.values()) {
+ if (info instanceof ManagedIndex) {
+ ((ManagedIndex) info).getIndexEntryStorage().truncate();
}
-
- txn.commit();
- } finally {
- txn.exit();
}
}