[ 
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 four 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.

The row cache can also use more heap than configured.

# HeapMemoryManager does not count the row cache when it checks the heap limits 
of the memstore and the block cache, so the heap memory tuner can grow them 
into the heap reserved for the row cache.
# RowCells#heapSize and RowCacheKey#heapSize do not count the list of cells, 
the array header of the row key and the map entry of the cache, so the cache 
can hold more than row.cache.size.

Smaller issues:

# TableDescriptor#getRowCacheEnabled is added to a public interface without a 
default implementation.
# An explicit ROW_CACHE_ENABLED => false is hidden from the table attributes 
shown in the master UI, although it differs from an absent value, which falls 
back to row.cache.enabled.
# Mutations create row level barriers even when row.cache.size is 0.

This also adds a missing null check of the row cache in 
HRegion#getScannerWithResults and simplifies how the row cache is looked up on 
region close and in the region server metrics.

  was:
While reviewing the row cache implementation on the HBASE-29585 feature branch, 
I found the following issues. The first four 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.

        Summary: Fix consistency and memory accounting issues in the row cache  
(was: Fix consistency issues in the row cache)

> Fix consistency and memory accounting 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 four 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.
> The row cache can also use more heap than configured.
> # HeapMemoryManager does not count the row cache when it checks the heap 
> limits of the memstore and the block cache, so the heap memory tuner can grow 
> them into the heap reserved for the row cache.
> # RowCells#heapSize and RowCacheKey#heapSize do not count the list of cells, 
> the array header of the row key and the map entry of the cache, so the cache 
> can hold more than row.cache.size.
> Smaller issues:
> # TableDescriptor#getRowCacheEnabled is added to a public interface without a 
> default implementation.
> # An explicit ROW_CACHE_ENABLED => false is hidden from the table attributes 
> shown in the master UI, although it differs from an absent value, which falls 
> back to row.cache.enabled.
> # Mutations create row level barriers even when row.cache.size is 0.
> This also adds a missing null check of the row cache in 
> HRegion#getScannerWithResults and simplifies how the row cache is looked up 
> on region close and in the region server metrics.



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

Reply via email to