From 2d937bc0a827aa45bd918875982bb555e014d224 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 27 Mar 2014 10:48:04 -0700 Subject: [PATCH] consul: Only close the cursor for read-only transactions (mdb) --- consul/mdb_table.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/consul/mdb_table.go b/consul/mdb_table.go index c1fe6dee87..966024c06f 100644 --- a/consul/mdb_table.go +++ b/consul/mdb_table.go @@ -535,7 +535,11 @@ func (i *MDBIndex) iterate(tx *MDBTxn, prefix []byte, if err != nil { return err } - defer cursor.Close() + // Read-only cursors are NOT closed by MDB when a transaction + // either commits or aborts, so must be closed explicitly + if tx.readonly { + defer cursor.Close() + } var key, encRowId, objBytes []byte first := true