From d2328a1a0e2fa5f3592cd67b320fb8f223978659 Mon Sep 17 00:00:00 2001 From: "A. Sophie Blee-Goldman" Date: Fri, 12 Jul 2019 12:43:46 -0700 Subject: [PATCH] HOT FIX: close RocksDB objects in correct order (#7076) Reviewers: Bill Bejeck , Matthias J. Sax --- ...DBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java | 3 ++- .../apache/kafka/streams/state/internals/RocksDBStore.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java b/streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java index d28682a1ef4..5b892a27bf5 100644 --- a/streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java +++ b/streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter.java @@ -1384,7 +1384,8 @@ class RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter extends Options @Override public void close() { - columnFamilyOptions.close(); + // ColumnFamilyOptions should be closed last dbOptions.close(); + columnFamilyOptions.close(); } } diff --git a/streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java b/streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java index 0643e64a8be..bcc43720380 100644 --- a/streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java +++ b/streams/src/main/java/org/apache/kafka/streams/state/internals/RocksDBStore.java @@ -402,11 +402,13 @@ public class RocksDBStore implements KeyValueStore, BulkLoadingSt configSetter = null; } + // Important: do not rearrange the order in which the below objects are closed! + // Order of closing must follow: ColumnFamilyHandle > RocksDB > DBOptions > ColumnFamilyOptions dbAccessor.close(); + db.close(); userSpecifiedOptions.close(); wOptions.close(); fOptions.close(); - db.close(); filter.close(); cache.close();