[
https://issues.apache.org/jira/browse/HBASE-30340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107992#comment-18107992
]
Sercan Tekin edited comment on HBASE-30340 at 8/25/26 3:18 PM:
---------------------------------------------------------------
PR is provided -> https://github.com/apache/hbase/pull/8569
FYI [~zhangduo]
was (Author: JIRAUSER283532):
PR is provided -> https://github.com/apache/hbase/pull/8569
> CatalogJanitor can run concurrent scans due to incorrect alreadyRunning lock
> handling
> -------------------------------------------------------------------------------------
>
> Key: HBASE-30340
> URL: https://issues.apache.org/jira/browse/HBASE-30340
> Project: HBase
> Issue Type: Bug
> Components: master
> Affects Versions: 0.90.5
> Reporter: Sercan Tekin
> Priority: Critical
> Labels: pull-request-available
>
> {{CatalogJanitor.scan()}} can allow concurrent scans due to incorrect
> handling of the
> {{alreadyRunning}} lock.
> Currently, the lock acquisition is performed inside the {{try}} block:
> {code:java}
> try {
> if (!alreadyRunning.compareAndSet(false, true)) {
> return -1;
> }
> ...
> } finally {
> alreadyRunning.set(false);
> }
> {code}
> When a scan is already running, a concurrent scan fails the
> {{compareAndSet()}} and
> returns immediately. However, because the lock acquisition is inside the
> {{try}} block,
> the {{finally}} block is still executed and resets {{alreadyRunning}} to
> false.
> This allows another scan to acquire the lock while the original scan is still
> running.
> The lock acquisition should be moved before the {{try}} block:
> {code:java}
> if (!alreadyRunning.compareAndSet(false, true)) {
> return -1;
> }
> try {
> ...
> } finally {
> alreadyRunning.set(false);
> }
> {code}
> This prevents another scan from starting until the current scan has completed.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)