diff --git a/go.mod b/go.mod index a40fdf60..e743e90b 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,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 diff --git a/go.sum b/go.sum index ad033a53..37dcb395 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,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= diff --git a/vendor/github.com/tidwall/buntdb/buntdb.go b/vendor/github.com/tidwall/buntdb/buntdb.go index 9f17322b..6e612a7b 100644 --- a/vendor/github.com/tidwall/buntdb/buntdb.go +++ b/vendor/github.com/tidwall/buntdb/buntdb.go @@ -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 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 9fa75d35..5e6bc342 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -117,7 +117,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