consul: less aggressive deadlock timer. Fixes #389

This commit is contained in:
Armon Dadgar 2014-10-14 12:00:25 -07:00
parent af4a955037
commit d1d76856e6
1 changed files with 10 additions and 2 deletions

View File

@ -3,11 +3,12 @@ package consul
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/armon/gomdb"
"reflect" "reflect"
"strings" "strings"
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/armon/gomdb"
) )
var ( var (
@ -21,6 +22,13 @@ const (
// is not used by MDBTable, but is stored so that the client can map // is not used by MDBTable, but is stored so that the client can map
// back to the Raft index number // back to the Raft index number
lastIndexRowID = 0 lastIndexRowID = 0
// deadlockTimeout is a heuristic to detect a potential MDB deadlock.
// If we have a transaction that is left open indefinitely, it can
// prevent new transactions from making progress and deadlocking
// the system. If we fail to start a transaction after this long,
// assume a potential deadlock and panic.
deadlockTimeout = 30 * time.Second
) )
/* /*
@ -215,7 +223,7 @@ func (t *MDBTable) StartTxn(readonly bool, mdbTxn *MDBTxn) (*MDBTxn, error) {
var err error var err error
// Panic if we deadlock acquiring a transaction // Panic if we deadlock acquiring a transaction
timeout := time.AfterFunc(5*time.Second, func() { timeout := time.AfterFunc(deadlockTimeout, func() {
panic("Timeout starting MDB transaction, potential deadlock") panic("Timeout starting MDB transaction, potential deadlock")
}) })
defer timeout.Stop() defer timeout.Stop()