EungsopYoo commented on code in PR #7901:
URL: https://github.com/apache/hbase/pull/7901#discussion_r3168018154
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java:
##########
@@ -3435,6 +3473,15 @@ private void updateDeleteLatestVersionTimestamp(Cell
cell, Get get, int count, b
@Override
public void put(Put put) throws IOException {
TraceUtil.trace(() -> {
+ // Put with TTL is not allowed on tables with row cache enabled, because
cached rows cannot
+ // track TTL expiration
+ if (isRowCacheEnabled) {
+ if (put.getTTL() != Long.MAX_VALUE) {
+ throw new DoNotRetryIOException(
+ "Tables with row cache enabled do not allow setting TTL on Puts");
+ }
+ }
Review Comment:
Good point — turned out to be feasible. Done.
Quick verification: I was initially worried that `Get` results don't carry
TTL tags (the design doc assumed this), but that's actually a *client-side*
property — the RPC codec strips tags. **Server-side** cells delivered to
`RowCache` preserve their TTL tag (carried forward by
`TagUtil.carryForwardTTLTag` during mutation, the same tag
`ScanQueryMatcher.isCellTTLExpired` reads). Confirmed with a probe test against
a live region.
Implementation:
- `RowCells` now precomputes the earliest TTL expiration time across its
cells during construction. Cells without a TTL tag yield `Long.MAX_VALUE`, so
`RowCells.isExpired(now)` is an `O(1)` `long` comparison on every cache hit —
no per-cell tag iteration on the hot path.
- `RowCache.tryGetFromCache`: if the row is expired, evict and fall back to
the storage read path.
- `RowCache.cache`: skip caching when results are empty (otherwise an
evicted-then-empty row would be re-cached as an empty entry).
- `HRegion.put`: removed the guard that rejected Puts with TTL.
CF-level TTL still disables the row cache via `canCacheRow`'s `isDefaultTtl`
check; that policy is unchanged for now.
Commit:
https://github.com/apache/hbase/pull/7901/commits/d8fef38bfc02906f0314397a588371be43fa6bf2
--
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]