MB-24376: Stop rangeRead on invalid Seqno
An exception is thrown if the start of the readRange is updated with a
value x < 0 || x > endSeqno, as this should not be done.
When updating an item which is currently covered by a rangeRead, the
following states occur in the seqList:
A₁ B₂ C₃ Initial items
[A₁ B₂ C₃] rangeRead to highSeqno
{ Write Lock
[A₁ B₂ C₃] A₋₁ ** Update; A₁ marked stale, new OSV appended.
NB: this is before queueDirty updates seqNo
[A₁ B₂ C₃] A₄ Seqno updated in queueDirty
}
RangeReads do not hold the write lock, and stop only upon either
reaching the end of the seqList, or reading an item with
seqno > endSeqno.
There is a brief window at the state marked ** in which a rangeRead
may try to update the start of the readRange with -1:
- rangeRead (endSeqno 3) reads C₃ normally
- proceeds to next item in the seqList
- checks if seqno > endSeqno - !(-1 > 3), don't stop yet
- update the start of the readRange with -1
This patch ends the readRange if the current item has a seqno < 0.
Change-Id: Ia1e53e4c40705b673c1f01e1b15fecbed5dff2fc
Reviewed-on: http://review.couchbase.org/78353
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Manu Dhundi <manu@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>