Ran
|
Files
164
|
Run time
5s
|
Badge
Embed ▾
README BADGES
|
push
github
db/pebbledb: make WriteTx.Discard safe to call again The interface always documented that Discard was safe to call after Commit, and presumably after Discard too, and it's a good idea. However, the pebbledb implementation lead to a data race, as explained in the added Discard method comment. I suspect that this race existed for some time, but it was rather rare. It seems to have surfaced recently on October 10th with commit 19c6d6851, which added more Discard calls in the form of: v.tx.Discard() + v.store.NoStateWriteTx.Discard() It turns out that, if NoStateWriteTx is simply a wrapper over the other tx we were already discarding, this would trigger the race with relatively high probability. Rather than trying to keep track of which transactions have already been discarded or committed, which is very easy prone to mistakes, make Discard properly safe to call at any point. While here, make Commit loudly error if called after itself or Discard. That's definitely a bug that we should surface quickly.
11476 of 22114 relevant lines covered (51.89%)
2907.06 hits per line
Coverage | ∆ | File | Lines | Relevant | Covered | Missed | Hits/Line |
---|