Repository: samza
Updated Branches:
  refs/heads/master 9d404bc51 -> 345f9f233


Fixed test failure for TestRocksDbKeyValueStoreJava#testIterate

RocksDB Snapshots and any iterators obtained from them need to be closed before 
the store is closed.

Otherwise the process aborts with the following message (at least on OSX):
`Assertion failed: (is_last_reference), function ~ColumnFamilyData, file 
db/column_family.cc, line 457.`

Author: Prateek Maheshwari <[email protected]>

Reviewers: Jagadish V <[email protected]>

Closes #513 from prateekm/rocksdb-test-fi


Project: http://git-wip-us.apache.org/repos/asf/samza/repo
Commit: http://git-wip-us.apache.org/repos/asf/samza/commit/345f9f23
Tree: http://git-wip-us.apache.org/repos/asf/samza/tree/345f9f23
Diff: http://git-wip-us.apache.org/repos/asf/samza/diff/345f9f23

Branch: refs/heads/master
Commit: 345f9f2333cdfea65c69e88594f6a5d6ba856145
Parents: 9d404bc
Author: Prateek Maheshwari <[email protected]>
Authored: Thu May 10 09:21:12 2018 -0700
Committer: xiliu <[email protected]>
Committed: Thu May 10 09:21:12 2018 -0700

----------------------------------------------------------------------
 .../samza/storage/kv/TestRocksDbKeyValueStoreJava.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/samza/blob/345f9f23/samza-kv-rocksdb/src/test/java/org/apache/samza/storage/kv/TestRocksDbKeyValueStoreJava.java
----------------------------------------------------------------------
diff --git 
a/samza-kv-rocksdb/src/test/java/org/apache/samza/storage/kv/TestRocksDbKeyValueStoreJava.java
 
b/samza-kv-rocksdb/src/test/java/org/apache/samza/storage/kv/TestRocksDbKeyValueStoreJava.java
index 672beac..a69010c 100644
--- 
a/samza-kv-rocksdb/src/test/java/org/apache/samza/storage/kv/TestRocksDbKeyValueStoreJava.java
+++ 
b/samza-kv-rocksdb/src/test/java/org/apache/samza/storage/kv/TestRocksDbKeyValueStoreJava.java
@@ -64,14 +64,18 @@ public class TestRocksDbKeyValueStoreJava {
     KeyValueSnapshot<byte[], byte[]> snapshot = store.snapshot(firstKey, 
lastKey);
     // Make sure the cached Iterable won't change when new elements are added
     store.put(genKey(outputStream, prefix, 200), genValue());
-    assertTrue(Iterators.size(snapshot.iterator()) == 100);
-
+    KeyValueIterator<byte[], byte[]> iterator = snapshot.iterator();
+    assertTrue(Iterators.size(iterator) == 100);
+    iterator.close();
     List<Integer> keys = new ArrayList<>();
-    for (Entry<byte[], byte[]> entry : snapshot) {
+    KeyValueIterator<byte[], byte[]> iterator2 = snapshot.iterator();
+    while (iterator2.hasNext()) {
+      Entry<byte[], byte[]> entry = iterator2.next();
       int key = Ints.fromByteArray(Arrays.copyOfRange(entry.getKey(), 
prefix.getBytes().length, entry.getKey().length));
       keys.add(key);
     }
     assertEquals(keys, IntStream.rangeClosed(0, 
99).boxed().collect(Collectors.toList()));
+    iterator2.close();
 
     outputStream.close();
     snapshot.close();

Reply via email to