From a69f9b85e4869a48394f1697ca4df08a3c3f21f2 Mon Sep 17 00:00:00 2001 From: Riyaz Faizullabhoy Date: Fri, 6 May 2016 17:39:23 -0700 Subject: [PATCH 1/2] Make default 60s timeout for rethindkb (default is 0) Signed-off-by: Riyaz Faizullabhoy --- storage/rethinkdb/bootstrap.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/storage/rethinkdb/bootstrap.go b/storage/rethinkdb/bootstrap.go index fcc08e4c05..896e1d3fd3 100644 --- a/storage/rethinkdb/bootstrap.go +++ b/storage/rethinkdb/bootstrap.go @@ -3,11 +3,15 @@ package rethinkdb import ( "fmt" "strings" + "time" "github.com/Sirupsen/logrus" "gopkg.in/dancannon/gorethink.v2" ) +// Wait for 60 seconds maximum on Wait() calls for rethink +var timeoutOpt = gorethink.WaitOpts{Timeout: time.Minute.Seconds()} + func makeDB(session *gorethink.Session, name string) error { _, err := gorethink.DBCreate(name).RunWrite(session) if err != nil { @@ -17,7 +21,7 @@ func makeDB(session *gorethink.Session, name string) error { return err } - resp, err := gorethink.DB(name).Wait().Run(session) + resp, err := gorethink.DB(name).Wait(timeoutOpt).Run(session) if resp != nil { resp.Close() } @@ -41,7 +45,7 @@ func (t Table) term(dbName string) gorethink.Term { } func (t Table) wait(session *gorethink.Session, dbName string) error { - resp, err := t.term(dbName).Wait().Run(session) + resp, err := t.term(dbName).Wait(timeoutOpt).Run(session) if resp != nil { resp.Close() From 6c87dbe4c6248d59793d20fa37203df4c9d0886e Mon Sep 17 00:00:00 2001 From: Riyaz Faizullabhoy Date: Mon, 9 May 2016 13:25:07 -0700 Subject: [PATCH 2/2] Remove wait after dbCreate Signed-off-by: Riyaz Faizullabhoy --- storage/rethinkdb/bootstrap.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/storage/rethinkdb/bootstrap.go b/storage/rethinkdb/bootstrap.go index 896e1d3fd3..e7cd50f985 100644 --- a/storage/rethinkdb/bootstrap.go +++ b/storage/rethinkdb/bootstrap.go @@ -18,14 +18,7 @@ func makeDB(session *gorethink.Session, name string) error { if strings.Contains(err.Error(), "already exists") { return nil } - - return err } - resp, err := gorethink.DB(name).Wait(timeoutOpt).Run(session) - if resp != nil { - resp.Close() - } - return err }