Commit 29ffb326 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cf4baa94
...@@ -41,11 +41,11 @@ ...@@ -41,11 +41,11 @@
// That might be useful to pass transactions through API boundaries. // That might be useful to pass transactions through API boundaries.
// //
// //
// Contrary to transaction/py there is no relation in between transaction and current thread - // Contrary to transaction/py there is no relation in between transaction and
// a transaction scope is managed completely by programmer. In particular it is // current thread - a transaction scope is managed completely by programmer. In
// possible to use one transaction in several goroutines simultaneously. // particular it is possible to use one transaction in several goroutines
// // simultaneously. There can be also several in-progress transactions running
// There can be also several in-progress transactions running simultaneously. // simultaneously, even in one goroutine.
// //
// //
// Two-phase commit // Two-phase commit
...@@ -259,7 +259,7 @@ type Synchronizer interface { ...@@ -259,7 +259,7 @@ type Synchronizer interface {
// //
// The transaction manager calls BeforeCompletion before txn is going // The transaction manager calls BeforeCompletion before txn is going
// to be completed - either committed or aborted. // to be completed - either committed or aborted.
BeforeCompletion(ctx context.Context, txn Transaction) error BeforeCompletion(txn Transaction) // XXX +ctx, error?
// AfterCompletion is called after corresponding transaction was completed. // AfterCompletion is called after corresponding transaction was completed.
// //
......
...@@ -17,7 +17,7 @@ import ( ...@@ -17,7 +17,7 @@ import (
"context" "context"
"sync" "sync"
"lab.nexedi.com/kirr/go123/xerr" //"lab.nexedi.com/kirr/go123/xerr"
) )
// transaction implements Transaction. // transaction implements Transaction.
...@@ -80,8 +80,6 @@ func (txn *transaction) Commit(ctx context.Context) error { ...@@ -80,8 +80,6 @@ func (txn *transaction) Commit(ctx context.Context) error {
// Abort implements Transaction. // Abort implements Transaction.
func (txn *transaction) Abort() { func (txn *transaction) Abort() {
ctx := context.Background() // FIXME stub
var datav []DataManager var datav []DataManager
var syncv []Synchronizer var syncv []Synchronizer
...@@ -103,23 +101,24 @@ func (txn *transaction) Abort() { ...@@ -103,23 +101,24 @@ func (txn *transaction) Abort() {
n := len(syncv) n := len(syncv)
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
wg.Add(n) wg.Add(n)
errv := make([]error, n) //errv := make([]error, n)
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
i := i i := i
go func() { go func() {
defer wg.Done() defer wg.Done()
errv[i] = syncv[i].BeforeCompletion(ctx, txn) syncv[i].BeforeCompletion(txn)
//errv[i] = syncv[i].BeforeCompletion(ctx, txn)
}() }()
} }
wg.Wait() wg.Wait()
ev := xerr.Errorv{} //ev := xerr.Errorv{}
for _, err := range errv { //for _, err := range errv {
ev.Appendif(err) // ev.Appendif(err)
} //}
errBeforeCompletion := ev.Err() //errBeforeCompletion := ev.Err()
xerr.Context(&errBeforeCompletion, "transaction: abort:") //xerr.Context(&errBeforeCompletion, "transaction: abort:")
// XXX if before completion = err -> skip data.Abort()? state -> AbortFailed? // XXX if before completion = err -> skip data.Abort()? state -> AbortFailed?
......
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