Commit 9ca9a7c3 by bergquist

bus: dont start transaction when creating session

parent 629eab0b
...@@ -29,7 +29,6 @@ func startSession(ctx context.Context) *DBSession { ...@@ -29,7 +29,6 @@ func startSession(ctx context.Context) *DBSession {
if !ok { if !ok {
newSess := newSession() newSess := newSession()
newSess.Begin()
return newSess return newSess
} }
......
...@@ -17,6 +17,10 @@ func (ss *SqlStore) inTransactionWithRetry(ctx context.Context, fn func(ctx cont ...@@ -17,6 +17,10 @@ func (ss *SqlStore) inTransactionWithRetry(ctx context.Context, fn func(ctx cont
sess := startSession(ctx) sess := startSession(ctx)
defer sess.Close() defer sess.Close()
if err := sess.Begin(); err != nil {
return err
}
withValue := context.WithValue(ctx, ContextSessionName, sess) withValue := context.WithValue(ctx, ContextSessionName, sess)
err := fn(withValue) err := fn(withValue)
...@@ -59,6 +63,7 @@ func inTransactionWithRetryCtx(ctx context.Context, callback dbTransactionFunc, ...@@ -59,6 +63,7 @@ func inTransactionWithRetryCtx(ctx context.Context, callback dbTransactionFunc,
var err error var err error
sess := startSession(ctx) sess := startSession(ctx)
defer sess.Close() defer sess.Close()
if err = sess.Begin(); err != nil { if err = sess.Begin(); err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment