aboutsummaryrefslogtreecommitdiff
path: root/db.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2015-05-21 09:50:13 -0600
committerBen Johnson <benbjohnson@yahoo.com>2015-05-21 09:50:13 -0600
commita03d52a9ddf084a281b7dc0c4f47dca2c8ba2c3c (patch)
tree131831c69b1490356cb829c60829392410c860a1 /db.go
parentMerge pull request #377 from benbjohnson/close-race (diff)
downloaddedo-a03d52a9ddf084a281b7dc0c4f47dca2c8ba2c3c.tar.gz
dedo-a03d52a9ddf084a281b7dc0c4f47dca2c8ba2c3c.tar.xz
Add docs for dependent transactions.
This commit adds documentation to clarify that read-only and read-write transactions should not be mixed in the same goroutine as it can cause deadlocks during remapping. See: https://github.com/boltdb/bolt/issues/378
Diffstat (limited to 'db.go')
-rw-r--r--db.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/db.go b/db.go
index f5ca05e..d39c4aa 100644
--- a/db.go
+++ b/db.go
@@ -401,6 +401,11 @@ func (db *DB) close() error {
// will cause the calls to block and be serialized until the current write
// transaction finishes.
//
+// Transactions should not be depedent on one another. Opening a read
+// transaction and a write transaction in the same goroutine can cause the
+// writer to deadlock because the database periodically needs to re-mmap itself
+// as it grows and it cannot do that while a read transaction is open.
+//
// IMPORTANT: You must close read-only transactions after you are finished or
// else the database will not reclaim old pages.
func (db *DB) Begin(writable bool) (*Tx, error) {