Update BuntDB

This commit is contained in:
tidwall 2021-04-01 12:30:59 -07:00
parent 6bb9f8f54c
commit 189de6496a
4 changed files with 23 additions and 5 deletions

2
go.mod
View File

@ -15,7 +15,7 @@ require (
github.com/peterh/liner v1.2.1
github.com/streadway/amqp v1.0.0
github.com/tidwall/btree v0.4.2
github.com/tidwall/buntdb v1.2.2
github.com/tidwall/buntdb v1.2.3
github.com/tidwall/geoindex v1.4.3
github.com/tidwall/geojson v1.2.7
github.com/tidwall/gjson v1.7.4

4
go.sum
View File

@ -184,8 +184,8 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tidwall/btree v0.4.2 h1:aLwwJlG+InuFzdAPuBf9YCAR1LvSQ9zhC5aorFPlIPs=
github.com/tidwall/btree v0.4.2/go.mod h1:huei1BkDWJ3/sLXmO+bsCNELL+Bp2Kks9OLyQFkzvA8=
github.com/tidwall/buntdb v1.2.2 h1:46G3ulKw8NYo0JAvsZkf7Xq1c8OHOPRuHQVTfL6z+lE=
github.com/tidwall/buntdb v1.2.2/go.mod h1:+i/gBwYOHWG19wLgwMXFLkl00twh9+VWkkaOhuNQ4PA=
github.com/tidwall/buntdb v1.2.3 h1:AoGVe4yrhKmnEPHrPrW5EUOATHOCIk4VtFvd8xn/ZtU=
github.com/tidwall/buntdb v1.2.3/go.mod h1:+i/gBwYOHWG19wLgwMXFLkl00twh9+VWkkaOhuNQ4PA=
github.com/tidwall/cities v0.1.0 h1:CVNkmMf7NEC9Bvokf5GoSsArHCKRMTgLuubRTHnH0mE=
github.com/tidwall/cities v0.1.0/go.mod h1:lV/HDp2gCcRcHJWqgt6Di54GiDrTZwh1aG2ZUPNbqa4=
github.com/tidwall/geoindex v1.4.3 h1:zowx7LtzibIE6JPbL6CRgVgw9qp13dJ8Pzfa4/f+4us=

View File

@ -1176,7 +1176,25 @@ func (tx *Tx) Commit() error {
// Flushing the buffer only once per transaction.
// If this operation fails then the write did failed and we must
// rollback.
if _, err = tx.db.file.Write(tx.db.buf); err != nil {
var n int
n, err = tx.db.file.Write(tx.db.buf)
if err != nil {
if n > 0 {
// There was a partial write to disk.
// We are possibly out of disk space.
// Delete the partially written bytes from the data file by
// seeking to the previously known position and performing
// a truncate operation.
// At this point a syscall failure is fatal and the process
// should be killed to avoid corrupting the file.
pos, err := tx.db.file.Seek(-int64(n), 1)
if err != nil {
panic(err)
}
if err := tx.db.file.Truncate(pos); err != nil {
panic(err)
}
}
tx.rollbackInner()
}
if tx.db.config.SyncPolicy == Always {

2
vendor/modules.txt vendored
View File

@ -148,7 +148,7 @@ github.com/streadway/amqp
# github.com/tidwall/btree v0.4.2
## explicit
github.com/tidwall/btree
# github.com/tidwall/buntdb v1.2.2
# github.com/tidwall/buntdb v1.2.3
## explicit
github.com/tidwall/buntdb
# github.com/tidwall/cities v0.1.0