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

Duo Zhang resolved HBASE-30340.
-------------------------------
    Fix Version/s: 4.0.0-alpha-1
                   2.7.0
                   3.1.0
                   3.0.1
                   2.6.8
                   2.5.17
     Hadoop Flags: Reviewed
       Resolution: Fixed

Pushed to all active branches.

Thanks [~sercan.tekin]!

> 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
>            Assignee: Sercan Tekin
>            Priority: Critical
>              Labels: pull-request-available
>             Fix For: 4.0.0-alpha-1, 2.7.0, 3.1.0, 3.0.1, 2.6.8, 2.5.17
>
>
> {{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)

Reply via email to