mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
mvcc/backend: remove t.tx.DB()==nil checks with GracefulStop
Revert https://github.com/coreos/etcd/pull/6662. Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
cd470f9ccd
commit
8ffd58fb3b
@ -166,19 +166,11 @@ func (t *batchTx) commit(stop bool) {
|
|||||||
t.backend.mu.RLock()
|
t.backend.mu.RLock()
|
||||||
defer t.backend.mu.RUnlock()
|
defer t.backend.mu.RUnlock()
|
||||||
|
|
||||||
// batchTx.commit(true) calls *bolt.Tx.Commit, which
|
// t.tx.DB()==nil if 'CommitAndStop' calls 'batchTx.commit(true)',
|
||||||
// initializes *bolt.Tx.db and *bolt.Tx.meta as nil,
|
// which initializes *bolt.Tx.db and *bolt.Tx.meta as nil; panics t.tx.Size().
|
||||||
// and subsequent *bolt.Tx.Size() call panics.
|
// Server must make sure 'batchTx.commit(false)' does not follow
|
||||||
//
|
// 'batchTx.commit(true)' (e.g. stopping backend, and inflight Hash call).
|
||||||
// This nil pointer reference panic happens when:
|
|
||||||
// 1. batchTx.commit(false) from newBatchTx
|
|
||||||
// 2. batchTx.commit(true) from stopping backend
|
|
||||||
// 3. batchTx.commit(false) from inflight mvcc Hash call
|
|
||||||
//
|
|
||||||
// Check if db is nil to prevent this panic
|
|
||||||
if t.tx.DB() != nil {
|
|
||||||
atomic.StoreInt64(&t.backend.size, t.tx.Size())
|
atomic.StoreInt64(&t.backend.size, t.tx.Size())
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user