This was noticed in cockroachdb/cockroach#81511.
This field is declared to be atomic:
|
// buf[:written] has already been filled with fragments. Updated atomically. |
|
written int32 |
Yet we read from it non-atomically here:
A trivial fix would be to update the read-site to read atomically.
While we're in here, we should audit the read/write call-sites to make sure we're honoring the atomic call-site.
It may even be worth some sugar in the struct to highlight the fact that the field is atomic (i.e. block.atomic.writer). I believe I've seen this patten adopted elsewhere.
This was noticed in cockroachdb/cockroach#81511.
This field is declared to be atomic:
pebble/record/log_writer.go
Lines 25 to 26 in 9bd4314
Yet we read from it non-atomically here:
pebble/record/log_writer.go
Line 678 in 9bd4314
A trivial fix would be to update the read-site to read atomically.
While we're in here, we should audit the read/write call-sites to make sure we're honoring the atomic call-site.
It may even be worth some sugar in the struct to highlight the fact that the field is atomic (i.e.
block.atomic.writer). I believe I've seen this patten adopted elsewhere.