Giter Club home page Giter Club logo

Comments (5)

jeffkayser2 avatar jeffkayser2 commented on July 23, 2024

I would attempt to change it myself, but I'm not sure what the correct logic should look like.

from bbolt.

jeffkayser2 avatar jeffkayser2 commented on July 23, 2024
// meta retrieves the current meta page reference.
func (db *DB) meta() *meta {
        // We have to return the meta with the highest txid which doesn't fail
        // validation. Otherwise, we can cause errors when in fact the database is
        // in a consistent state. metaA is the one with the higher txid.

        fmt.Printf("bolt: db: meta: meta0: %T,%v, meta1: %T,%v, db.meta0.txid: %T,%v, db.meta1.txid: %T,%v\n",
                db.meta0,db.meta0,db.meta1,db.meta1,db.meta0.txid,db.meta0.txid,db.meta1.txid,db.meta1.txid)

        metaA := db.meta0
        metaB := db.meta1
        if db.meta1.txid > db.meta0.txid {
                metaA = db.meta1
                metaB = db.meta0
        }

        // Use higher meta page if valid. Otherwise fallback to previous, if valid.
        if err := metaA.validate(); err == nil {
                return metaA
        } else if err := metaB.validate(); err == nil {
                return metaB
        }

        // This should never be reached, because both meta1 and meta0 were validated
        // on mmap() and we do fsync() on every write.
        panic("bolt.DB.meta(): invalid meta pages")
}

from bbolt.

jeffkayser2 avatar jeffkayser2 commented on July 23, 2024

Suggested change in tx.go:

func (tx *Tx) rollback() {
        if tx.db == nil {
                return
        }
        if tx.writable {
                tx.db.freelist.rollback(tx.meta.txid)
                currFreelist := tx.db.meta().freelist
                if currFreelist != pgidNoFreelist {
                        tx.db.freelist.reload(tx.db.page(currFreelist))
                }
        }
        tx.close()
}

The above change fixed my particular issue, but I have no idea if the logic is correct.

from bbolt.

WIZARD-CXY avatar WIZARD-CXY commented on July 23, 2024

@jeffkayser2 will be fixed, sorry take so long...

from bbolt.

ahrtr avatar ahrtr commented on July 23, 2024

Resolved. Please try with the latest source code.

from bbolt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.