@@ -116,9 +116,9 @@ func (c *Coordinate) dispatchTxn(reqs []*Elem[OP], startTS uint64) (*CoordinateR
116116 return nil , errors .WithStack (ErrTxnCommitTSRequired )
117117 }
118118
119- logs := txnRequests ( startTS , commitTS , defaultTxnLockTTLms , primary , reqs )
120-
121- r , err := c . transactionManager . Commit ( logs )
119+ r , err := c . transactionManager . Commit ([] * pb. Request {
120+ onePhaseTxnRequest ( startTS , commitTS , primary , reqs ),
121+ } )
122122 if err != nil {
123123 return nil , errors .WithStack (err )
124124 }
@@ -209,7 +209,9 @@ func (c *Coordinate) redirect(ctx context.Context, reqs *OperationGroup[OP]) (*C
209209 if len (primary ) == 0 {
210210 return nil , errors .WithStack (ErrTxnPrimaryKeyRequired )
211211 }
212- requests = txnRequests (reqs .StartTS , 0 , defaultTxnLockTTLms , primary , reqs .Elems )
212+ requests = []* pb.Request {
213+ onePhaseTxnRequest (reqs .StartTS , 0 , primary , reqs .Elems ),
214+ }
213215 } else {
214216 for _ , req := range reqs .Elems {
215217 requests = append (requests , c .toRawRequest (req ))
@@ -261,33 +263,17 @@ func elemToMutation(req *Elem[OP]) *pb.Mutation {
261263 panic ("unreachable" )
262264}
263265
264- func txnRequests (startTS , commitTS , lockTTLms uint64 , primaryKey []byte , reqs []* Elem [OP ]) []* pb.Request {
265- meta := & pb.Mutation {
266- Op : pb .Op_PUT ,
267- Key : []byte (txnMetaPrefix ),
268- Value : EncodeTxnMeta (TxnMeta {PrimaryKey : primaryKey , LockTTLms : lockTTLms , CommitTS : 0 }),
269- }
270-
271- prepareMuts := make ([]* pb.Mutation , 0 , len (reqs )+ 1 )
272- prepareMuts = append (prepareMuts , meta )
273- for _ , req := range reqs {
274- prepareMuts = append (prepareMuts , elemToMutation (req ))
275- }
276-
277- commitMeta := & pb.Mutation {
278- Op : pb .Op_PUT ,
279- Key : []byte (txnMetaPrefix ),
280- Value : EncodeTxnMeta (TxnMeta {PrimaryKey : primaryKey , LockTTLms : 0 , CommitTS : commitTS }),
281- }
282- commitMuts := make ([]* pb.Mutation , 0 , len (reqs )+ 1 )
283- commitMuts = append (commitMuts , commitMeta )
266+ func onePhaseTxnRequest (startTS , commitTS uint64 , primaryKey []byte , reqs []* Elem [OP ]) * pb.Request {
267+ muts := make ([]* pb.Mutation , 0 , len (reqs )+ 1 )
268+ muts = append (muts , txnMetaMutation (primaryKey , 0 , commitTS ))
284269 for _ , req := range reqs {
285- commitMuts = append (commitMuts , & pb. Mutation { Op : pb . Op_PUT , Key : req . Key } )
270+ muts = append (muts , elemToMutation ( req ) )
286271 }
287-
288- return []* pb.Request {
289- {IsTxn : true , Phase : pb .Phase_PREPARE , Ts : startTS , Mutations : prepareMuts },
290- {IsTxn : true , Phase : pb .Phase_COMMIT , Ts : startTS , Mutations : commitMuts },
272+ return & pb.Request {
273+ IsTxn : true ,
274+ Phase : pb .Phase_NONE ,
275+ Ts : startTS ,
276+ Mutations : muts ,
291277 }
292278}
293279
0 commit comments