Summary: In our testing cluster, we found large amount tombstone has been promoted to kValue type from kMerge after reaching the top level of compaction. Since we used to only collecting tombstone in merge operator, those tombstones can never be collected. This PR addresses the issue by adding a GC step in compaction filter, which is only for kValue type records. Since those record already reached the top of compaction (no earlier data exists) we can safely remove them in compaction filter without worrying old data appears. This PR also removes an old optimization in cassandra merge operator for single merge operands. We need to do GC even on a single operand, so the optimation does not make sense anymore. Closes https://github.com/facebook/rocksdb/pull/2855 Reviewed By: sagar0 Differential Revision: D5806445 Pulled By: wpc fbshipit-source-id: 6eb25629d4ce917eb5e8b489f64a6aa78c7d270b
24 lines
972 B
C++
24 lines
972 B
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#include <jni.h>
|
|
|
|
#include "include/org_rocksdb_CassandraCompactionFilter.h"
|
|
#include "utilities/cassandra/cassandra_compaction_filter.h"
|
|
|
|
/*
|
|
* Class: org_rocksdb_CassandraCompactionFilter
|
|
* Method: createNewCassandraCompactionFilter0
|
|
* Signature: (ZI)J
|
|
*/
|
|
jlong Java_org_rocksdb_CassandraCompactionFilter_createNewCassandraCompactionFilter0(
|
|
JNIEnv* env, jclass jcls, jboolean purge_ttl_on_expiration,
|
|
jint gc_grace_period_in_seconds) {
|
|
auto* compaction_filter = new rocksdb::cassandra::CassandraCompactionFilter(
|
|
purge_ttl_on_expiration, gc_grace_period_in_seconds);
|
|
// set the native handle to our native compaction filter
|
|
return reinterpret_cast<jlong>(compaction_filter);
|
|
}
|