[ 
https://issues.apache.org/jira/browse/HBASE-30604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eungsop Yoo updated HBASE-30604:
--------------------------------
    Description: 
While reviewing the row cache implementation on the HBASE-29585 feature branch, 
I found the following issues. The first three can return stale or wrong rows 
from the row cache without any error.

# HRegion#mutateRowsWithLocks does not invalidate the row cache. It calls 
batchMutate with a MutationBatchOperation directly and skips the row cache 
barrier, so rows mutated through MultiRowMutationEndpoint stay stale in the 
cache.
# RowCache#canCacheRow does not check Get#getMaxVersions. A Get reading 
multiple versions can populate the cache, and a later single-version Get is 
then served all cached versions. The opposite direction is also wrong.
# A Get can cache a stale row when a mutation of the same row completes while 
the Get is reading the row. The row level barrier only tells whether a mutation 
is in progress, so if a mutation starts and finishes between the read and the 
cache population, the old row stays in the cache until the next mutation of the 
row.
# The same problem exists at the region level for bulk loads. A Get that starts 
after the bulk load increases the row cache sequence number of the region can 
read the region before the bulk-loaded files are added, and cache the old row 
under the current key after the bulk load finishes.
# The barrier counters are incremented outside computeIfAbsent. A concurrent 
removal can drop the counter from the map between the lookup and the increment, 
which lets a mutation run without a barrier.

For #3, RowCache will register a pending-load token for the row before the 
read. A mutation removes the token, and the Get populates the cache only if its 
token is still registered. For the bulk load case, the row cache sequence 
number is increased again when the bulk load finishes.

This also adds a missing null check of the row cache in 
HRegion#getScannerWithResults and cleans up the row cache eviction on region 
close.

  was:
While reviewing the row cache implementation on the HBASE-29585 feature branch, 
I found the following issues. The first three can return stale or wrong rows 
from the row cache without any error.

# HRegion#mutateRowsWithLocks does not invalidate the row cache. It calls 
batchMutate with a MutationBatchOperation directly and skips the row cache 
barrier, so rows mutated through MultiRowMutationEndpoint stay stale in the 
cache.
# RowCache#canCacheRow does not check Get#getMaxVersions. A Get reading 
multiple versions can populate the cache, and a later single-version Get is 
then served all cached versions. The opposite direction is also wrong.
# A Get can cache a stale row when a mutation of the same row completes while 
the Get is reading the row. The row level barrier only tells whether a mutation 
is in progress, so if a mutation starts and finishes between the read and the 
cache population, the old row stays in the cache until the next mutation of the 
row.
# The barrier counters are incremented outside computeIfAbsent. A concurrent 
removal can drop the counter from the map between the lookup and the increment, 
which lets a mutation run without a barrier.

For #3, RowCache will register a pending-load token for the row before the 
read. A mutation removes the token, and the Get populates the cache only if its 
token is still registered.

This also adds a missing null check of the row cache in 
HRegion#getScannerWithResults and cleans up the row cache eviction on region 
close.


> Fix consistency issues in the row cache
> ---------------------------------------
>
>                 Key: HBASE-30604
>                 URL: https://issues.apache.org/jira/browse/HBASE-30604
>             Project: HBase
>          Issue Type: Sub-task
>            Reporter: Eungsop Yoo
>            Assignee: Eungsop Yoo
>            Priority: Major
>
> While reviewing the row cache implementation on the HBASE-29585 feature 
> branch, I found the following issues. The first three can return stale or 
> wrong rows from the row cache without any error.
> # HRegion#mutateRowsWithLocks does not invalidate the row cache. It calls 
> batchMutate with a MutationBatchOperation directly and skips the row cache 
> barrier, so rows mutated through MultiRowMutationEndpoint stay stale in the 
> cache.
> # RowCache#canCacheRow does not check Get#getMaxVersions. A Get reading 
> multiple versions can populate the cache, and a later single-version Get is 
> then served all cached versions. The opposite direction is also wrong.
> # A Get can cache a stale row when a mutation of the same row completes while 
> the Get is reading the row. The row level barrier only tells whether a 
> mutation is in progress, so if a mutation starts and finishes between the 
> read and the cache population, the old row stays in the cache until the next 
> mutation of the row.
> # The same problem exists at the region level for bulk loads. A Get that 
> starts after the bulk load increases the row cache sequence number of the 
> region can read the region before the bulk-loaded files are added, and cache 
> the old row under the current key after the bulk load finishes.
> # The barrier counters are incremented outside computeIfAbsent. A concurrent 
> removal can drop the counter from the map between the lookup and the 
> increment, which lets a mutation run without a barrier.
> For #3, RowCache will register a pending-load token for the row before the 
> read. A mutation removes the token, and the Get populates the cache only if 
> its token is still registered. For the bulk load case, the row cache sequence 
> number is increased again when the bulk load finishes.
> This also adds a missing null check of the row cache in 
> HRegion#getScannerWithResults and cleans up the row cache eviction on region 
> close.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to