You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by Jean-Daniel Cryans <jd...@apache.org> on 2010/08/24 01:17:14 UTC

Heads up! New locking in HRegion

Hackers,

I just committed HBASE-2915 which is a rework of the locking story
inside HRegion that fixes a couple of deadlocks. Some issues may
remain, so have your jstacks ready in case some weirdness happens (and
yes, we need another run of jcarder).

Some details for those interested:

We used to have a couple of locks in HRegion: split, newScanner, and
splitsAndCloses. Stack removed the first, and I merged the two others
into one called "lock" (crazy name, I know). It is now required that
every operation that comes from the user (put, get, icv, etc) be
enclosed in this pattern:

startRegionOperation();
try {
  // nifty code
} finally {
  closeRegionOperation();
}

It will take care of checking if the region is closing before trying
to get a readLock (bonus is that it won't be occupying handlers) and
then it will check if the region was closed while we were waiting to
acquire the lock. In both cases, it'll throw a NSRE if the region is
closing/closed. For flush/compact, the handling is different as we
don't expect to see NSREs... although that could be refactored at some
point I guess. Split and close are the only operations that are
permitted to take a writeLock.

Now let's cut another 0.89!

J-D