github-actions[bot] commented on code in PR #61666:
URL: https://github.com/apache/doris/pull/61666#discussion_r3121419807
##########
cloud/src/common/config.h:
##########
@@ -158,6 +158,12 @@ CONF_mBool(enable_mvcc_meta_check, "false");
CONF_mInt64(mow_job_key_check_expiration_diff_seconds, "600"); // 10min
+// KV cache config
+CONF_mBool(enable_tablet_index_cache, "true");
+CONF_mInt64(ms_tablet_index_cache_capacity, "10000");
+CONF_mInt64(recycler_tablet_index_cache_capacity, "10000");
+CONF_mInt64(tablet_index_cache_ttl_seconds, "0"); // 0 means no TTL
Review Comment:
These knobs are declared mutable, but both `ms_cache_manager()` and
`recycler_cache_manager()` build function-local static caches from them once.
After the first cache lookup, changing `ms_tablet_index_cache_capacity`,
`recycler_tablet_index_cache_capacity`, or `tablet_index_cache_ttl_seconds` at
runtime has no effect until restart. Either make them non-mutable or add a live
reconfiguration path for the existing caches.
##########
cloud/src/meta-service/meta_service.cpp:
##########
@@ -216,6 +266,9 @@ void get_tablet_idx(MetaServiceCode& code, std::string&
msg, Transaction* txn,
<< " idx_pb_tablet_id=" << tablet_idx.tablet_id() << "
key=" << hex(key);
return;
}
Review Comment:
Once this entry is cached, there is no invalidation when
`meta_tablet_idx_key` is later rewritten or removed. That becomes a correctness
problem with the new cache because `fix_tablet_db_id()` can update the
persisted `db_id`, and `InstanceRecycler::recycle_tablets()` can delete the
key, but `get_tablet_idx()` will still serve the stale `TabletIndexPB` forever
when `tablet_index_cache_ttl_seconds == 0` (the default). A concrete failure
mode is `get_rowset()`: after `/fix_tablet_db_id`, it still derives
`partition_version_key` from the old `db_id` and can read the wrong
partition-version state. Please invalidate or refresh this cache anywhere
`meta_tablet_idx_key` is updated or removed.
##########
cloud/src/recycler/util.cpp:
##########
@@ -266,6 +307,11 @@ int get_tablet_idx(TxnKv* txn_kv, const std::string&
instance_id, int64_t tablet
<< " idx_pb_tablet_id=" << tablet_idx.tablet_id() << "
key=" << hex(key);
return -1;
}
+
+ // Cache put
Review Comment:
`get_tablet_idx()` now caches every successful lookup here, but there is no
invalidation when the same tablet-index row is repaired later. If recycler
cached an old `db_id` and `/fix_tablet_db_id` (or another repair path) updates
the KV row afterward, `check_lazy_txn_finished()` still uses the stale cached
`db_id` to build `partition_version_key`. On `TXN_KEY_NOT_FOUND` that function
returns `true`, so a pending lazy txn can be treated as finished and the tablet
may be recycled early. Please either invalidate this cache on tablet-index
rewrites or avoid using cached routing info for the lazy-txn safety check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]