github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/iface/txnif/consts.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package txnif 16 17 import "github.com/matrixorigin/matrixone/pkg/container/types" 18 19 var UncommitTS types.TS 20 21 func init() { 22 UncommitTS = types.MaxTs() 23 } 24 25 type TxnState int32 26 27 const ( 28 TxnStateActive TxnState = iota 29 TxnStatePreparing 30 //TxnStatePrepared only for 2PC 31 TxnStatePrepared 32 //TxnStateCommittingFinished only for 2PC txn runs on coordinator 33 TxnStateCommittingFinished 34 TxnStateRollbacking 35 //TxnStateCommitted , TxnStateRollbacked, and TxnStateUnknown are final states. 36 TxnStateCommitted 37 TxnStateRollbacked 38 TxnStateUnknown 39 ) 40 41 type TxnStatus int32 42 43 const ( 44 // TxnStatusActive TxnStatus = iota 45 // TxnStatusPrepared 46 // TxnStatusCommittingFinished 47 // TxnStatusCommitted 48 // TxnStatusRollbacked 49 ) 50 51 type DedupType uint8 52 53 const ( 54 FullDedup DedupType = iota 55 FullSkipWorkSpaceDedup 56 IncrementalDedup 57 ) 58 59 func TxnStrState(state TxnState) string { 60 switch state { 61 case TxnStateActive: 62 return "Active" 63 case TxnStatePreparing: 64 return "Preparing" 65 case TxnStatePrepared: 66 return "Prepared" 67 case TxnStateCommittingFinished: 68 return "CommittingFinished" 69 case TxnStateRollbacking: 70 return "Rollbacking" 71 case TxnStateCommitted: 72 return "Committed" 73 case TxnStateRollbacked: 74 return "Rollbacked" 75 case TxnStateUnknown: 76 return "Unknown" 77 } 78 panic("state not support") 79 } 80 81 const ( 82 FreezePhase = "Phase_Freeze" 83 RollbackPhase = "Phase_Rollback" 84 PrePreparePhase = "Phase_PrePrepare" 85 PrepareCommitPhase = "Phase_PrepareCommit" 86 PreApplyCommitPhase = "Phase_PreApplyCommit" 87 ApplyCommitPhase = "Phase_ApplyCommit" 88 ) 89 90 const ( 91 TraceStart = iota 92 TracePreparing 93 TracePrepareWalWait 94 TracePrepareWal 95 TracePreapredWait 96 TracePrepared 97 )