From ac1149a3f50e5b74f5c7129f26039af0f14807bb Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Mon, 2 Feb 2015 08:27:34 -0700 Subject: Persist sequence-only changes. This commit fixes a bug where only calling NextSequence() on a Bucket does not cause the Bucket to be peristed. The simple fix is to simply materialize the root node so that the bucket is flushed out during commit. Thanks to Matthew Dawson (@MJDSys) for reporting. https://github.com/boltdb/bolt/issues/296 --- bucket.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bucket.go') diff --git a/bucket.go b/bucket.go index 28832fc..470689b 100644 --- a/bucket.go +++ b/bucket.go @@ -332,6 +332,12 @@ func (b *Bucket) NextSequence() (uint64, error) { return 0, ErrTxNotWritable } + // Materialize the root node if it hasn't been already so that the + // bucket will be saved during commit. + if b.rootNode == nil { + _ = b.node(b.root, nil) + } + // Increment and return the sequence. b.bucket.sequence++ return b.bucket.sequence, nil -- cgit v1.2.3