iamaleksey commented on code in PR #3495:
URL: https://github.com/apache/cassandra/pull/3495#discussion_r1743736074
##########
src/java/org/apache/cassandra/journal/Journal.java:
##########
@@ -542,8 +542,11 @@ private void advanceSegment(ActiveSegment<K, V> oldSegment)
// if a segment is ready, take it now, otherwise wait for the
allocator thread to construct it
if (availableSegment != null)
{
+ ActiveSegment<K, V> nextSegment = availableSegment;
+ availableSegment = null;
// success - change allocatingFrom and activeSegments
(which must be kept in order) before leaving the critical section
- addNewActiveSegment(currentSegment = availableSegment);
+ addNewActiveSegment(nextSegment);
Review Comment:
The update between `currentSegment` and the `Segments` can't happen
simultaneously, unfortunately, so we have to make a decision regarding which
happens first. Current order is intentional. The comment above explicitly says
so (though variable names need an update). Code that is potentially affected by
this needs to take this possibility into account. `Journal#getActiveSegment()`
is an example of this - there, we check `currentSegment` first, and then
`segments()` if need be. Similarly, `Journal#isFlushed()` must do the same
thing.
##########
src/java/org/apache/cassandra/journal/Journal.java:
##########
@@ -610,11 +613,10 @@ private void runNormal() throws InterruptedException
// synchronized to prevent thread interrupts while performing
IO operations and also
// clear interrupted status to prevent
ClosedByInterruptException in createSegment()
- synchronized (this)
+ synchronized (Journal.this)
Review Comment:
Is this an accidental change? I don't think this is desired.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]