You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixeshypermodeinc/dgraph#5456 .
This PR fixes the crash that could occur when a block was
read from the cache.
There was a logical race condition. The following sequence
of events could occur which would cause the crash.
1. An iterator makes `t.Block(idx)` call
2. The `t.Block` function finds the block in the cache.
The newly found block has `ref=1` which means it was
held only by the cache.
3. The `t.Block` function is holding the block and at the
same time the block gets evicted from the cache. The
existing ref of the block was `1` so the cache eviction
would decrement the ref and make it `0`. When the ref
becomes `0`, the block is added to the `sync.Pool` and
is ready to be reused.
4. While the block got evicted from the cache, the iterator
received the block and it incremented the ref from
`0` to `1` and starts using this.
Since the block was inserted into the syncPool in the 3rd
event, it could be modified by anyone while the iterator is
using it.
0 commit comments