From abfacf568407f0fa384f75cac134b4ebd9cf33ec Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Thu, 30 Aug 2018 05:44:58 -0700 Subject: [PATCH] Fix data race in AutoCommit() Detected via https://circleci.com/gh/rqlite/rqlite/2223. --- sqlite3.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sqlite3.go b/sqlite3.go index d8c5b8d..e48594f 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -648,6 +648,8 @@ func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool // AutoCommit return which currently auto commit or not. func (c *SQLiteConn) AutoCommit() bool { + c.mu.Lock() + defer c.mu.Unlock() return int(C.sqlite3_get_autocommit(c.db)) != 0 }