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();