concourse icon indicating copy to clipboard operation
concourse copied to clipboard

RangeLocks coalesce connected ranges and therefore can remove too much protection when unlocked

Open jtnelson opened this issue 2 years ago • 0 comments

The isRangeBlocked logic relies on a collection that does not keep track of distinct locked ranges when they are connected. As a result, when a range lock is released, protection is removed from the intersection of ranges protected by other held range locks.

In RangeLockServiceTest.java

@Test
    public void testRangeLocksKeepTrackOfDistinctRangesEvenWhenConnected() {
        String key = "foo";
        Lock a = rangeLockService.getReadLock(key, Operator.LESS_THAN_OR_EQUALS,
                Convert.javaToThrift(10));
        Lock b = rangeLockService.getReadLock(key, Operator.GREATER_THAN,
                Convert.javaToThrift(5));
        a.lock();
        b.lock();
        RangeToken token = RangeToken.forWriting(Text.wrap(key),
                Value.wrap(Convert.javaToThrift(7)));
        Assert.assertTrue(
                rangeLockService.isRangeBlocked(LockType.WRITE, token));
        b.unlock();
        Assert.assertTrue(
                rangeLockService.isRangeBlocked(LockType.WRITE, token));
    }

jtnelson avatar Sep 21 '22 11:09 jtnelson