Merge lp:~pbeaman/akiban-persistit/fix_912514_again into lp:akiban-persistit

Proposed by Peter Beaman
Status: Merged
Approved by: Nathan Williams
Approved revision: 309
Merged at revision: 309
Proposed branch: lp:~pbeaman/akiban-persistit/fix_912514_again
Merge into: lp:akiban-persistit
Diff against target: 111 lines (+47/-2)
4 files modified
src/main/java/com/persistit/Exchange.java (+2/-2)
src/main/java/com/persistit/Persistit.java (+1/-0)
src/test/java/com/persistit/ConfigurationTest.java (+8/-0)
src/test/java/com/persistit/unit/ExchangeTest.java (+36/-0)
To merge this branch: bzr merge lp:~pbeaman/akiban-persistit/fix_912514_again
Reviewer Review Type Date Requested Status
Akiban Build User Needs Fixing
Nathan Williams Approve
Review via email: mp+107879@code.launchpad.net

Description of the change

Fix two small bugs detected while running the stress tests.

(a) start-stop-plan reuses a Persistit instance; releaseAllResources() now sets the initialized flag to false so that this will work correctly.

(b) fetchAndRemove is still broken - some bits need to be masked in two conditionals that test whether the from and to key of a remove operation are adjacent.

This branch fixes both bugs and adds trivial unit tests.

(Note - this is the second merge proposal for this branch. We pulled the first one because of uncertainty over some other changes.)

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

Looks good.

review: Approve
Revision history for this message
Akiban Build User (build-akiban) wrote :

There was one failure during build/test:

* unknown exception (check log)

review: Needs Fixing
Revision history for this message
Nathan Williams (nwilliams) wrote :

Unrelated LBJ timeout waiting for dumbo.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/main/java/com/persistit/Exchange.java'
--- src/main/java/com/persistit/Exchange.java 2012-05-25 18:50:59 +0000
+++ src/main/java/com/persistit/Exchange.java 2012-05-29 21:03:19 +0000
@@ -3559,13 +3559,13 @@
35593559
3560 private void removeFetchFirst(Buffer buffer1, int foundAt1, Buffer buffer2, int foundAt2) throws PersistitException {3560 private void removeFetchFirst(Buffer buffer1, int foundAt1, Buffer buffer2, int foundAt2) throws PersistitException {
3561 if (buffer1 == buffer2) {3561 if (buffer1 == buffer2) {
3562 if (buffer1.nextKeyBlock(foundAt1) == foundAt2) {3562 if (buffer1.nextKeyBlock(foundAt1) == (foundAt2 & P_MASK)) {
3563 buffer1.fetch(foundAt1 | EXACT_MASK, _spareValue);3563 buffer1.fetch(foundAt1 | EXACT_MASK, _spareValue);
3564 }3564 }
3565 } else {3565 } else {
3566 if (buffer1.getRightSibling() == buffer2.getPageAddress() && buffer1.nextKeyBlock(foundAt1) == -1) {3566 if (buffer1.getRightSibling() == buffer2.getPageAddress() && buffer1.nextKeyBlock(foundAt1) == -1) {
3567 foundAt1 = buffer2.toKeyBlock(0);3567 foundAt1 = buffer2.toKeyBlock(0);
3568 if (buffer2.nextKeyBlock(foundAt1) == foundAt2) {3568 if (buffer2.nextKeyBlock(foundAt1) == (foundAt2 & P_MASK)) {
3569 buffer2.fetch(foundAt1 | EXACT_MASK, _spareValue);3569 buffer2.fetch(foundAt1 | EXACT_MASK, _spareValue);
3570 }3570 }
3571 }3571 }
35723572
=== modified file 'src/main/java/com/persistit/Persistit.java'
--- src/main/java/com/persistit/Persistit.java 2012-05-25 18:50:59 +0000
+++ src/main/java/com/persistit/Persistit.java 2012-05-29 21:03:19 +0000
@@ -1794,6 +1794,7 @@
1794 _intArrayThreadLocal.set(null);1794 _intArrayThreadLocal.set(null);
1795 _keyThreadLocal.set(null);1795 _keyThreadLocal.set(null);
1796 _valueThreadLocal.set(null);1796 _valueThreadLocal.set(null);
1797 _initialized.set(false);
1797 }1798 }
17981799
1799 /**1800 /**
18001801
=== modified file 'src/test/java/com/persistit/ConfigurationTest.java'
--- src/test/java/com/persistit/ConfigurationTest.java 2012-05-25 18:50:59 +0000
+++ src/test/java/com/persistit/ConfigurationTest.java 2012-05-29 21:03:19 +0000
@@ -222,6 +222,14 @@
222 assertTrue("Should contain expected text 'hwdemo'", configuration.getJournalPath().contains("hwdemo"));222 assertTrue("Should contain expected text 'hwdemo'", configuration.getJournalPath().contains("hwdemo"));
223 }223 }
224224
225 @Test
226 public void canReinitialize() throws Exception {
227 _persistit.close();
228 assertTrue("Should have closed all volumes", _persistit.getVolumes().isEmpty());
229 _persistit.initialize(_persistit.getConfiguration());
230 assertTrue("Should have reopened volumes", !_persistit.getVolumes().isEmpty());
231 }
232
225 private Configuration testLoadPropertiesBufferSpecificationsHelper(final Properties properties) throws Exception {233 private Configuration testLoadPropertiesBufferSpecificationsHelper(final Properties properties) throws Exception {
226 Configuration configuration = new Configuration();234 Configuration configuration = new Configuration();
227 configuration.merge(properties);235 configuration.merge(properties);
228236
=== modified file 'src/test/java/com/persistit/unit/ExchangeTest.java'
--- src/test/java/com/persistit/unit/ExchangeTest.java 2012-05-25 18:50:59 +0000
+++ src/test/java/com/persistit/unit/ExchangeTest.java 2012-05-29 21:03:19 +0000
@@ -21,6 +21,7 @@
21package com.persistit.unit;21package com.persistit.unit;
2222
23import static org.junit.Assert.assertEquals;23import static org.junit.Assert.assertEquals;
24import static org.junit.Assert.assertTrue;
24import static org.junit.Assert.fail;25import static org.junit.Assert.fail;
2526
26import java.util.Random;27import java.util.Random;
@@ -30,6 +31,7 @@
30import com.persistit.Exchange;31import com.persistit.Exchange;
31import com.persistit.Key;32import com.persistit.Key;
32import com.persistit.KeyFilter;33import com.persistit.KeyFilter;
34import com.persistit.Transaction;
33import com.persistit.Volume;35import com.persistit.Volume;
34import com.persistit.exception.ConversionException;36import com.persistit.exception.ConversionException;
35import com.persistit.exception.PersistitException;37import com.persistit.exception.PersistitException;
@@ -281,6 +283,40 @@
281 assertEquals(1, ex.getValue().getInt());283 assertEquals(1, ex.getValue().getInt());
282 }284 }
283285
286 @Test
287 public void testRemoveAndFetch() throws Exception {
288 testRemoveAndFetch(false);
289 testRemoveAndFetch(true);
290 }
291
292 private void testRemoveAndFetch(boolean inTransaction) throws Exception {
293 Exchange ex = _persistit.getExchange("persistit", "gogo", true);
294 Transaction txn = ex.getTransaction();
295 ex.getValue().put(RED_FOX);
296 for (int i = 1; i < 10000; i++) {
297 if (inTransaction) {
298 txn.begin();
299 }
300 ex.to(i).store();
301 if (inTransaction) {
302 txn.commit();
303 txn.end();
304 }
305 }
306 for (int i = 1; i < 10000; i++) {
307 if (inTransaction) {
308 txn.begin();
309 }
310 ex.getValue().clear();
311 ex.to(i).fetchAndRemove();
312 assertTrue("A value was fetched", ex.getValue().isDefined());
313 if (inTransaction) {
314 txn.commit();
315 txn.end();
316 }
317 }
318 }
319
284 /*320 /*
285 * This function is "borrowed" from the YCSB benchmark framework developed321 * This function is "borrowed" from the YCSB benchmark framework developed
286 * by Yahoo Research.322 * by Yahoo Research.

Subscribers

People subscribed via source and target branches