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

.

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