[
https://issues.apache.org/jira/browse/HBASE-810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12624176#action_12624176
]
Jim Kellerman commented on HBASE-810:
-------------------------------------
To reiterate, the following changes should be made:
- Remove HStore read lock in StoreFileScanner constructor
- HRegion.get(byte [] row, byte [] column, long timestamp, int numVersions)
(which all the other variants of get call) and HRegion.compactStores() should
take out splitsAndClosesLock.readLock().lock() at the start of the method, and
release it at the end, using try - finally
- In HRegion.close, move the wait for active scanners outside the acquisition
of splitsAndClosesLock and prevent new scanners by adding a reentrant read
write lock named something like new scanner lock. New code would look something
like:
{code}
private final ReentrantReadWriteLock newScannerLock = new
ReentrantReadWriteLock();
...
In close(boolean):
newScannerLock.writeLock().lock();
LOG.debug("Scanners disabled for region " + this);
try {
// Wait for active scanners to finish.
synchronized (activeScannerCount) {
while (activeScannerCount.get() != 0) {
LOG.debug("waiting for " + activeScannerCount.get() +
" scanners to finish");
try {
activeScannerCount.wait();
} catch (InterruptedException e) {
// continue
}
}
}
LOG.debug("No more active scanners for region " + this);
splitsAndClosesLock.writeLock().lock();
LOG.debug("Updates disabled for region " + this);
try {
...
} finally {
splitsAndClosesLock.writeLock().unlock();
}
} finally {
newScannerLock.writeLock().unlock();
}
{code}
Then change the use of splitsAndClosesLock in getScanner to use newScannerLock
instead.
New sequencing diagram forthcoming.
> Prevent temporary deadlocks when, during a scan with write operations, the
> region splits
> ----------------------------------------------------------------------------------------
>
> Key: HBASE-810
> URL: https://issues.apache.org/jira/browse/HBASE-810
> Project: Hadoop HBase
> Issue Type: Bug
> Affects Versions: 0.2.0
> Reporter: Jean-Daniel Cryans
> Priority: Blocker
> Fix For: 0.2.1, 0.3.0
>
> Attachments: lock-sequencing.jpg, locking-compatibility.jpg
>
>
> HBASE-804 was not about the good problem, this one is. Anyone that iterates
> through the results of a scanner and that rewrites data back into the row at
> each iteration will hit a UnknownScannerException if a split occurs. See the
> stack in the referred jira. Timeline :
> Split occurs, acquires a write lock and waits for scanners to finish
> The scanner in the custom code iterates and writes data until the write is
> blocked by the lock
> deadlock
> The scanner timeouts thus the region splits but the USE will be thrown when
> next() is called
> Inside a Map, the task will simply be retried when the first one fails.
> Elsewhere, it becomes more complicated.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.