Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix freelist corruption on tx.WriteTo #67

Merged
merged 2 commits into from
Nov 16, 2017

Conversation

heyitsanthony
Copy link
Contributor

lol

Was causing freelist corruption on tx.WriteTo
Reliably triggers consistency check failures on ramdisk without freelist
free fix.
@heyitsanthony heyitsanthony changed the title Fix freelist corruption Fix freelist corruption on tx.WriteTo Nov 16, 2017
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@f4ebd07). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #67   +/-   ##
=========================================
  Coverage          ?   85.47%           
=========================================
  Files             ?        9           
  Lines             ?     1859           
  Branches          ?        0           
=========================================
  Hits              ?     1589           
  Misses            ?      160           
  Partials          ?      110
Impacted Files Coverage Δ
freelist.go 81.7% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f4ebd07...41fefe7. Read the comment docs.

@xiang90
Copy link
Contributor

xiang90 commented Nov 16, 2017

@jpbetz

@jpbetz
Copy link
Contributor

jpbetz commented Nov 16, 2017

lgtm

@jpbetz
Copy link
Contributor

jpbetz commented Nov 16, 2017

@gyuho @xiang90 Can we cut a new bbolt version containing this fix?

@gyuho
Copy link
Contributor

gyuho commented Nov 16, 2017

@jpbetz https://github.com/coreos/bbolt/releases/tag/v1.3.1-coreos.5 :)

Thanks @heyitsanthony !

Comment on lines 133 to +137
if ok {
delete(f.allocs, p.id)
} else if (p.flags & (freelistPageFlag | metaPageFlag)) != 0 {
// Safe to claim txid as allocating since these types are private to txid.
allocTxid = txid
} else if (p.flags & freelistPageFlag) != 0 {
// Freelist is always allocated by prior tx.
allocTxid = txid - 1
Copy link
Member

@ahrtr ahrtr Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can fix the issue, but it's a little complicated. No need to handle freelist as a special case. I think it can be as simple as below.

$ git diff
diff --git a/freelist.go b/freelist.go
index fdf8a36..4a15832 100644
--- a/freelist.go
+++ b/freelist.go
@@ -118,9 +118,6 @@ func (f *freelist) free(txid common.Txid, p *common.Page) {
        allocTxid, ok := f.allocs[p.Id()]
        if ok {
                delete(f.allocs, p.Id())
-       } else if p.IsFreelistPage() {
-               // Freelist is always allocated by prior tx.
-               allocTxid = txid - 1
        }
 
        for id := p.Id(); id <= p.Id()+common.Pgid(p.Overflow()); id++ {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants