sercanCyberVision opened a new pull request, #8569:
URL: https://github.com/apache/hbase/pull/8569
`CatalogJanitor.scan()` can allow concurrent scans due to incorrect handling
of the
`alreadyRunning` lock.
**ROOT CAUSE**
Currently, the lock acquisition is performed inside the `try` block:
```
try {
if (!alreadyRunning.compareAndSet(false, true)) {
return -1;
}
...
} finally {
alreadyRunning.set(false);
}
```
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.
**SOLUTION**
The lock acquisition should be moved before the `try` block:
```
if (!alreadyRunning.compareAndSet(false, true)) {
return -1;
}
try {
...
} finally {
alreadyRunning.set(false);
}
```
This prevents another scan from starting until the current scan has
completed.
--
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]