|
|
|
@ -6,7 +6,6 @@ import ( |
|
|
|
|
|
|
|
"github.com/dtm-labs/dtm/dtmcli/dtmimp" |
|
|
|
"github.com/dtm-labs/dtm/dtmcli/logger" |
|
|
|
"github.com/dtm-labs/dtm/dtmutil" |
|
|
|
"go.mongodb.org/mongo-driver/bson" |
|
|
|
"go.mongodb.org/mongo-driver/mongo" |
|
|
|
) |
|
|
|
@ -34,7 +33,7 @@ func (bb *BranchBarrier) MongoCall(mc *mongo.Client, busiCall func(mongo.Session |
|
|
|
currentAffected, rerr := mongoInsertBarrier(sc, mc, bb.TransType, bb.Gid, bb.BranchID, bb.Op, bid, bb.Op) |
|
|
|
logger.Debugf("originAffected: %d currentAffected: %d", originAffected, currentAffected) |
|
|
|
|
|
|
|
if rerr == nil && bb.Op == dtmutil.BarrierOpMsg && currentAffected == 0 { // for msg's DoAndSubmit, repeated insert should be rejected.
|
|
|
|
if rerr == nil && bb.Op == dtmimp.BarrierOpMsg && currentAffected == 0 { // for msg's DoAndSubmit, repeated insert should be rejected.
|
|
|
|
return ErrDuplicated |
|
|
|
} |
|
|
|
|
|
|
|
@ -55,16 +54,16 @@ func (bb *BranchBarrier) MongoCall(mc *mongo.Client, busiCall func(mongo.Session |
|
|
|
// MongoQueryPrepared query prepared for redis
|
|
|
|
// experimental
|
|
|
|
func (bb *BranchBarrier) MongoQueryPrepared(mc *mongo.Client) error { |
|
|
|
_, err := mongoInsertBarrier(context.Background(), mc, bb.TransType, bb.Gid, dtmutil.BranchId00, dtmutil.BarrierOpMsg, dtmutil.BranchId01, "rollback") |
|
|
|
_, err := mongoInsertBarrier(context.Background(), mc, bb.TransType, bb.Gid, dtmimp.BranchId00, dtmimp.BarrierOpMsg, dtmimp.BarrierID01, "rollback") |
|
|
|
var result bson.M |
|
|
|
if err == nil { |
|
|
|
fs := strings.Split(dtmimp.BarrierTableName, ".") |
|
|
|
barrier := mc.Database(fs[0]).Collection(fs[1]) |
|
|
|
err = barrier.FindOne(context.Background(), bson.D{ |
|
|
|
{Key: "gid", Value: bb.Gid}, |
|
|
|
{Key: "branch_id", Value: dtmutil.BranchId00}, |
|
|
|
{Key: "op", Value: dtmutil.BarrierOpMsg}, |
|
|
|
{Key: "barrier_id", Value: dtmutil.BranchId01}, |
|
|
|
{Key: "branch_id", Value: dtmimp.BranchId00}, |
|
|
|
{Key: "op", Value: dtmimp.BarrierOpMsg}, |
|
|
|
{Key: "barrier_id", Value: dtmimp.BarrierID01}, |
|
|
|
}).Decode(&result) |
|
|
|
} |
|
|
|
var reason string |
|
|
|
|