Documentation
¶
Index ¶
- Constants
- Variables
- func BuildLocalDataSource(ctx context.Context, rel engine.Relation, ranges engine.RelData, txnOffset int) (source engine.DataSource, err error)
- func CheckTxnIsValid(txnOp client.TxnOperator) (err error)
- func CollectAndCalculateStats(ctx context.Context, req *updateStatsRequest, executor ConcurrentExecutor) (float64, error)
- func ConstructObjStatsByLoadObjMeta(ctx context.Context, metaLoc objectio.Location, fs fileservice.FileService) (stats objectio.ObjectStats, dataMeta objectio.ObjectDataMeta, err error)
- func DefaultNewRpcStreamToTnLogTailService(ctx context.Context, sid string, serviceAddr string, rpcClient morpc.RPCClient) (morpc.RPCClient, morpc.Stream, error)
- func ForeachCommittedObjects(createObjs map[objectio.ObjectNameShort]struct{}, ...) (err error)
- func ForeachSnapshotObjects(ts timestamp.Timestamp, ...) (err error)
- func ForeachTombstoneObject(ts types.TS, ...) error
- func ForeachVisibleObjects(state *logtailreplay.PartitionState, ts types.TS, ...) (err error)
- func GetChangedTableList(ctx context.Context, service string, eng engine.Engine, accs []uint64, ...) (err error)
- func GetMOTableStatsExecutor(service string, eng engine.Engine, sqlExecutor func() ie.InternalExecutor) func(ctx context.Context, task task.Task) error
- func GetPartitionStateStart(ctx context.Context, rel engine.Relation) (types.TS, error)
- func GetSnapshotReadFnWithHandler(...) ...
- func HandleShardingReadApproxObjectsNum(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadBuildReader(ctx context.Context, shard shard.TableShard, e engine.Engine, ...) ([]byte, error)
- func HandleShardingReadClose(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadCollectTombstones(ctx context.Context, shard shard.TableShard, eng engine.Engine, ...) ([]byte, error)
- func HandleShardingReadGetColumMetadataScanInfo(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadMergeObjects(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadNext(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadPrimaryKeysMayBeModified(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadPrimaryKeysMayBeUpserted(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadRanges(ctx context.Context, shard shard.TableShard, eng engine.Engine, ...) ([]byte, error)
- func HandleShardingReadRows(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadSize(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadStatus(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func HandleShardingReadVisibleObjectStats(ctx context.Context, shard shard.TableShard, engine engine.Engine, ...) ([]byte, error)
- func LinearSearchOffsetByValFactory(pk *vector.Vector) func(*vector.Vector) []int64
- func ListTnService(service string, appendFn func(service *metadata.TNService))
- func MockShardingLocalReader() engine.Reader
- func MockTableDelegate(tableDelegate engine.Relation, service shardservice.ShardService) (engine.Relation, error)
- func NewTableMetaReader(ctx context.Context, rel engine.Relation) (engine.Reader, error)
- func ScanSnapshotWithCurrentRanges(ctx context.Context, caller string, rel engine.Relation, ...) error
- type CCPRTxnCache
- func (c *CCPRTxnCache) OnFileWritten(objectName string)
- func (c *CCPRTxnCache) OnTxnCommit(txnID []byte)
- func (c *CCPRTxnCache) OnTxnRollback(txnID []byte)
- func (c *CCPRTxnCache) OnTxnUnknownResult(txnID []byte)
- func (c *CCPRTxnCache) WriteObject(ctx context.Context, objectName string, txnID []byte) (isNewFile bool, err error)
- type CheckpointChangesHandle
- type CloneTxnCache
- func (ctc CloneTxnCache) AddSharedFile(txnId []byte, name string)
- func (ctc CloneTxnCache) AddTxn(txnId []byte, snapshot int64)
- func (ctc CloneTxnCache) AddTxnLocalSharedFile(txnId []byte, name string)
- func (ctc CloneTxnCache) DeleteTxn(txnId []byte)
- func (ctc CloneTxnCache) IsSharedFile(txnId []byte, name string) bool
- func (ctc CloneTxnCache) IsTxnLocalSharedFile(txnId []byte, name string) bool
- func (ctc CloneTxnCache) RemoveTxnLocalSharedFile(txnId []byte, name string)
- type CombinedRelData
- func (r *CombinedRelData) AppendBlockInfo(blk *objectio.BlockInfo)
- func (r *CombinedRelData) AppendBlockInfoSlice(objectio.BlockInfoSlice)
- func (r *CombinedRelData) AppendShardID(id uint64)
- func (r *CombinedRelData) AttachTombstones(tombstones engine.Tombstoner) error
- func (r *CombinedRelData) BuildEmptyRelData(preAllocSize int) engine.RelData
- func (r *CombinedRelData) DataCnt() int
- func (r *CombinedRelData) DataSlice(begin, end int) engine.RelData
- func (r *CombinedRelData) GetBlockInfo(i int) objectio.BlockInfo
- func (r *CombinedRelData) GetBlockInfoSlice() objectio.BlockInfoSlice
- func (r *CombinedRelData) GetShardID(i int) uint64
- func (r *CombinedRelData) GetShardIDList() []uint64
- func (r *CombinedRelData) GetTombstones() engine.Tombstoner
- func (r *CombinedRelData) GetType() engine.RelDataType
- func (r *CombinedRelData) MarshalBinary() ([]byte, error)
- func (r *CombinedRelData) SetBlockInfo(i int, blk *objectio.BlockInfo)
- func (r *CombinedRelData) SetShardID(i int, id uint64)
- func (r *CombinedRelData) Split(i int) []engine.RelData
- func (r *CombinedRelData) String() string
- func (r *CombinedRelData) UnmarshalBinary(buf []byte) error
- type ConcurrentExecutor
- type DNStore
- type Engine
- func (e *Engine) AcquireQuota(v int64) (int64, bool)
- func (e *Engine) AllocateIDByKey(ctx context.Context, key string) (uint64, error)
- func (e *Engine) BuildBlockReaders(ctx context.Context, p any, ts timestamp.Timestamp, expr *plan.Expr, ...) ([]engine.Reader, error)
- func (e *Engine) Close() error
- func (e *Engine) Create(ctx context.Context, name string, op client.TxnOperator) error
- func (e *Engine) Database(ctx context.Context, name string, op client.TxnOperator) (engine.Database, error)
- func (e *Engine) Databases(ctx context.Context, op client.TxnOperator) ([]string, error)
- func (e *Engine) Delete(ctx context.Context, name string, op client.TxnOperator) (err error)
- func (e *Engine) FS() fileservice.FileService
- func (e *Engine) ForceGC(ctx context.Context, ts types.TS)
- func (e *Engine) GCCatalogCache(ctx context.Context, ago time.Duration) error
- func (e *Engine) GetCCPRTxnCache() *CCPRTxnCache
- func (e *Engine) GetGlobalStats() *GlobalStats
- func (e *Engine) GetLatestCatalogCache() *cache.CatalogCache
- func (e *Engine) GetMessageCenter() any
- func (e *Engine) GetNameById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, err error)
- func (e *Engine) GetOrCreateLatestPart(ctx context.Context, accId uint64, databaseId, tableId uint64) *logtailreplay.Partition
- func (e *Engine) GetRelationById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName, tableName string, rel engine.Relation, err error)
- func (e *Engine) GetService() string
- func (e *Engine) GetTNServices() []DNStore
- func (d *Engine) HandleMoTableStatsCtl(cmd string) string
- func (e *Engine) Hints() (h engine.Hints)
- func (e *Engine) InitLogTailPushModel(ctx context.Context, timestampWaiter client.TimestampWaiter) error
- func (e *Engine) LatestLogtailAppliedTime() timestamp.Timestamp
- func (d *Engine) LaunchMTSTasksForUT()
- func (e *Engine) LazyLoadLatestCkp(ctx context.Context, accId uint64, tableID uint64, tableName string, ...) (*logtailreplay.Partition, error)
- func (d *Engine) LogDynamicCtx() string
- func (d *Engine) MTSTableRows(ctx context.Context, accs, dbs, tbls []uint64, eng engine.Engine, ...) (sizes []uint64, err error)
- func (d *Engine) MTSTableSize(ctx context.Context, accs, dbs, tbls []uint64, eng engine.Engine, ...) (sizes []uint64, err error)
- func (e *Engine) New(ctx context.Context, op client.TxnOperator) error
- func (e *Engine) Nodes(isInternal bool, tenant string, username string, cnLabel map[string]string) (engine.Nodes, error)
- func (d *Engine) NotifyCleanDeletes()
- func (d *Engine) NotifyInsertNewTable()
- func (d *Engine) NotifyUpdateForgotten()
- func (e *Engine) PackerPool() *fileservice.Pool[*types.Packer]
- func (e *Engine) PrefetchTableMeta(ctx context.Context, key pb.StatsInfoKey) bool
- func (e *Engine) PushClient() *PushClient
- func (d *Engine) QueryTableStats(ctx context.Context, wantedStatsIdxes []int, accs, dbs, tbls []uint64, ...) (statsVals [][]any, err error, ok bool)
- func (d *Engine) QueryTableStatsByAccounts(ctx context.Context, wantedStatsIdxes []int, accs []uint64, forceUpdate bool, ...) (statsVals [][]any, retAcc []uint64, ok bool, err error)
- func (d *Engine) QueryTableStatsByDatabase(ctx context.Context, wantedStatsIdxes []int, dbIds []uint64, forceUpdate bool, ...) (statsVals [][]any, retDb []uint64, ok bool, err error)
- func (d *Engine) QueryTableStatsByTable(ctx context.Context, wantedStatsIdxes []int, tblIds []uint64, forceUpdate bool, ...) (statsVals [][]any, retTbls []uint64, ok bool, err error)
- func (e *Engine) ReleaseQuota(quota int64) (left uint64)
- func (e *Engine) ResetGCWorkerPool(pool *ants.Pool)
- func (e *Engine) RunGCScheduler(ctx context.Context)
- func (e *Engine) SetService(svr string)
- func (e *Engine) SetWorkspaceThreshold(commitThreshold, writeThreshold uint64) (commit, write uint64)
- func (e *Engine) Stats(ctx context.Context, key pb.StatsInfoKey, sync bool) *pb.StatsInfo
- func (e *Engine) TryToSubscribeTable(ctx context.Context, accId, dbID, tbID uint64, dbName, tblName string) error
- func (e *Engine) UnsubscribeTable(ctx context.Context, accId, dbID, tbID uint64) error
- type EngineOptions
- func WithCNTransferTxnLifespanThreshold(th time.Duration) EngineOptions
- func WithCommitWorkspaceThreshold(th uint64) EngineOptions
- func WithExtraWorkspaceThreshold(th uint64) EngineOptions
- func WithExtraWorkspaceThresholdQuota(quota uint64) EngineOptions
- func WithInsertEntryMaxCount(th int) EngineOptions
- func WithMoServerStateChecker(checker func() bool) EngineOptions
- func WithMoTableStatsConf(conf MoTableStatsConfig) EngineOptions
- func WithPrefetchOnSubscribed(th []string) EngineOptions
- func WithSQLExecFunc(f func() ie.InternalExecutor) EngineOptions
- func WithWriteWorkspaceThreshold(th uint64) EngineOptions
- type Entry
- type GlobalStats
- func (gs *GlobalStats) Get(ctx context.Context, key pb.StatsInfoKey, sync bool) *pb.StatsInfo
- func (gs *GlobalStats) GetBaseObjectCnt(key pb.StatsInfoKey) int64
- func (gs *GlobalStats) GetSamplingRatio(key pb.StatsInfoKey) float64
- func (gs *GlobalStats) PatchStats(key pb.StatsInfoKey, patch *PatchArgs) error
- func (gs *GlobalStats) PrefetchTableMeta(ctx context.Context, key pb.StatsInfoKey) bool
- func (gs *GlobalStats) RefreshWithMode(ctx context.Context, key pb.StatsInfoKey, samplingMode string) error
- func (gs *GlobalStats) RemoveTid(tableID uint64)
- type GlobalStatsConfig
- type GlobalStatsOption
- type IDGenerator
- type ItemEntry
- type LocalDisttaeDataSource
- func (ls *LocalDisttaeDataSource) ApplyTombstones(ctx context.Context, bid *objectio.Blockid, rowsOffset []int64, ...) ([]int64, error)
- func (ls *LocalDisttaeDataSource) Close()
- func (ls *LocalDisttaeDataSource) GetOrderBy() []*plan.OrderBySpec
- func (ls *LocalDisttaeDataSource) GetTombstones(ctx context.Context, bid *objectio.Blockid) (deletedRows objectio.Bitmap, err error)
- func (ls *LocalDisttaeDataSource) Next(ctx context.Context, cols []string, types []types.Type, seqNums []uint16, ...) (info *objectio.BlockInfo, state engine.DataState, err error)
- func (ls *LocalDisttaeDataSource) SetFilterZM(zm objectio.ZoneMap)
- func (ls *LocalDisttaeDataSource) SetOrderBy(orderby []*plan.OrderBySpec)
- func (ls *LocalDisttaeDataSource) String() string
- type MoTableStatsConfig
- type NoteLevel
- type PartitionChangesHandle
- type PatchArgs
- type PushClient
- func (c *PushClient) Disconnect() error
- func (c *PushClient) GetState() State
- func (c *PushClient) IsSubscribed(tblId uint64) bool
- func (c *PushClient) IsSubscriberReady() bool
- func (c *PushClient) LatestLogtailAppliedTime() timestamp.Timestamp
- func (c *PushClient) SetReconnectHandler(handler func())
- func (c *PushClient) SetSubscribeState(dbId, tblId uint64, state SubscribeState)
- func (c *PushClient) TryGC(ctx context.Context)
- func (c *PushClient) TryToSubscribeTable(ctx context.Context, accId, dbId, tblId uint64, dbName, tblName string) (err error)
- func (c *PushClient) UnsubscribeTable(ctx context.Context, accId, dbID, tbID uint64) error
- type ReaderPhase
- type ShuffleRangePartialUpdate
- type SnapshotGCConfig
- type SnapshotGCState
- type SnapshotManager
- func (sm *SnapshotManager) Add(dbID, tableID uint64, partition *logtailreplay.Partition, tableName string, ...) *logtailreplay.PartitionState
- func (sm *SnapshotManager) Find(dbID, tableID uint64, ts types.TS) *logtailreplay.PartitionState
- func (sm *SnapshotManager) GetConfig() SnapshotGCConfig
- func (sm *SnapshotManager) GetMetrics() *SnapshotMetrics
- func (sm *SnapshotManager) GetOrCreate(dbID, tableID uint64) *TrackedPartitions
- func (sm *SnapshotManager) Init()
- func (sm *SnapshotManager) MaybeStartGC()
- func (sm *SnapshotManager) RunGC()
- type SnapshotMetrics
- type State
- type SubTableStatus
- type SubscribeState
- type Summary
- type TableMetaReader
- func (r *TableMetaReader) Close() error
- func (r *TableMetaReader) GetOrderBy() []*plan.OrderBySpec
- func (r *TableMetaReader) GetTableDef() *plan.TableDef
- func (r *TableMetaReader) GetTxnInfo() string
- func (r *TableMetaReader) Read(ctx context.Context, _ []string, _ *plan.Expr, mp *mpool.MPool, ...) (end bool, err error)
- func (r *TableMetaReader) SetFilterZM(zoneMap objectio.ZoneMap)
- func (r *TableMetaReader) SetIndexParam(param *plan.IndexReaderParam)
- func (r *TableMetaReader) SetOrderBy(specs []*plan.OrderBySpec)
- type TrackedPartition
- type TrackedPartitions
- func (tp *TrackedPartitions) Add(partition *logtailreplay.Partition, tableName string, ts types.TS, ...) *logtailreplay.PartitionState
- func (tp *TrackedPartitions) Count() int
- func (tp *TrackedPartitions) Find(ts types.TS) *logtailreplay.PartitionState
- func (tp *TrackedPartitions) GC(maxAge time.Duration) int
- type Transaction
- func (txn *Transaction) Adjust(writeOffset uint64) error
- func (txn *Transaction) ApproximateInMemInsertSize() uint64
- func (txn *Transaction) BindTxnOp(op client.TxnOperator)
- func (txn *Transaction) CloneSnapshotWS() client.Workspace
- func (txn *Transaction) Commit(ctx context.Context) (reqs []txn.TxnRequest, err error)
- func (txn *Transaction) EndStatement()
- func (txn *Transaction) FinalizeCommit(context.Context)
- func (txn *Transaction) FinalizeCommitWithUnknownResult(context.Context)
- func (txn *Transaction) ForEachTableWrites(databaseId uint64, tableId uint64, offset int, f func(Entry))
- func (txn *Transaction) GCObjsByIdxRange(start, end int) (err error)
- func (txn *Transaction) GCObjsByStats(sl ...objectio.ObjectStats) (err error)
- func (txn *Transaction) GetCCPRTaskID() string
- func (txn *Transaction) GetHaveDDL() bool
- func (txn *Transaction) GetProc() *process.Process
- func (txn *Transaction) GetSQLCount() uint64
- func (txn *Transaction) GetSnapshotWriteOffset() int
- func (txn *Transaction) GetSyncProtectionJobID() string
- func (txn *Transaction) IncrSQLCount()
- func (txn *Transaction) IncrStatementID(ctx context.Context, commit bool) error
- func (txn *Transaction) IsCCPRTxn() bool
- func (txn *Transaction) PPString() string
- func (txn *Transaction) ReadOnly() bool
- func (txn *Transaction) Readonly() bool
- func (txn *Transaction) Rollback(ctx context.Context) error
- func (txn *Transaction) RollbackLastStatement(ctx context.Context) error
- func (txn *Transaction) SetCCPRTaskID(taskID string)
- func (txn *Transaction) SetCCPRTxn()
- func (txn *Transaction) SetCloneTxn(snapshot int64)
- func (txn *Transaction) SetHaveDDL(haveDDL bool)
- func (txn *Transaction) SetSyncProtectionJobID(jobID string)
- func (txn *Transaction) StartStatement()
- func (txn *Transaction) StashFlushedTombstones(stats objectio.ObjectStats)
- func (txn *Transaction) String() string
- func (txn *Transaction) UpdateSnapshotWriteOffset()
- func (txn *Transaction) WriteBatch(typ int, note string, accountId uint32, databaseId uint64, tableId uint64, ...) (genRowidVec *vector.Vector, err error)
- func (txn *Transaction) WriteFile(typ int, accountId uint32, databaseId, tableId uint64, ...) error
- func (txn *Transaction) WriteFileLocked(typ int, accountId uint32, databaseId, tableId uint64, ...) (err error)
- func (txn *Transaction) WriteFileLockedSkipTransfer(typ int, accountId uint32, databaseId, tableId uint64, ...) (err error)
- func (txn *Transaction) WriteOffset() uint64
- type TransferFlow
- type TransferOption
- type TxnIndexEntry
- type UT_ForceTransCheck
Constants ¶
const ( TableStatsTableSize = iota TableStatsTableRows TableStatsTObjectCnt TableStatsDObjectCnt TableStatsTBlockCnt TableStatsDBlockCnt TableStatsCnt )
const ( // MinExecutorConcurrency is the minimum concurrency for concurrentExecutor // which handles IO-intensive tasks (reading S3 objects). MinExecutorConcurrency = 32 // MaxExecutorConcurrency is the maximum concurrency for concurrentExecutor // to avoid extreme cases in high-core systems. MaxExecutorConcurrency = 108 // MinWorkerConcurrency is the minimum concurrency for updateWorker // which handles table-level update requests (coordinator role). MinWorkerConcurrency = 16 // WorkerConcurrencyRatio is the ratio of updateWorker concurrency to executor concurrency. // updateWorker concurrency = executorConcurrency / WorkerConcurrencyRatio WorkerConcurrencyRatio = 4 // SamplingThreshold is the minimum number of objects to enable sampling. // Below this threshold, full scan is used for accuracy. SamplingThreshold = 100 // MinSampleObjects is the minimum number of objects to sample. // Set equal to SamplingThreshold to ensure sampling count never drops below full scan count. MinSampleObjects = 100 // MaxSampleObjects is the maximum number of objects to sample. // Raise to allow large tables (>5w objects) to reach ~1-2% sampling. MaxSampleObjects = 5000 )
const ( // LargeTableThreshold is the object count threshold to classify a table as large. // Tables with fewer objects are considered small tables. LargeTableThreshold = 500 // LargeTableChangeRateThreshold is the minimum change rate to trigger stats update for large tables. // Change rate = pendingChanges / baseObjectCount LargeTableChangeRateThreshold = 0.05 // 5% // LargeTableMaxUpdateInterval is the maximum interval between stats updates for large tables. // Even if change rate is below threshold, update will be triggered after this interval. LargeTableMaxUpdateInterval = 30 * time.Minute )
const ( PREFETCH_THRESHOLD = 256 PREFETCH_ROUNDS = 24 SMALLSCAN_THRESHOLD = 150 LARGESCAN_THRESHOLD = 1500 )
const ( INSERT = iota DELETE ALTER // alter command for TN. Update batches for mo_tables and mo_columns will fall into the category of INSERT and DELETE. SOFT_DELETE_OBJECT // soft delete object command for TN )
const ( MO_DATABASE_ID_NAME_IDX = 1 MO_DATABASE_ID_ACCOUNT_IDX = 2 MO_DATABASE_LIST_ACCOUNT_IDX = 1 MO_TABLE_ID_NAME_IDX = 1 MO_TABLE_ID_DATABASE_ID_IDX = 2 MO_TABLE_ID_ACCOUNT_IDX = 3 MO_TABLE_LIST_DATABASE_ID_IDX = 1 MO_TABLE_LIST_ACCOUNT_IDX = 2 MO_PRIMARY_OFF = 2 INIT_ROWID_OFFSET = math.MaxUint32 )
const ( CommitWorkspaceThreshold uint64 = 1 * mpool.MB WriteWorkspaceThreshold uint64 = 5 * mpool.MB ExtraWorkspaceThreshold uint64 = 500 * mpool.MB InsertEntryThreshold = 5000 GCBatchOfFileCount int = 1000 GCPoolSize int = 5 CNTransferTxnLifespanThreshold = time.Second * 5 )
const (
AllColumns = "*"
)
const DefaultLoadParallism = 20
const StreamReaderLease = time.Minute * 2
Variables ¶
var (
GcCycle = 10 * time.Second
)
var ( // MinUpdateInterval is the minimal interval to update stats info as it // is necessary to update stats every time. MinUpdateInterval = time.Second * 15 )
var NewPartitionStateChangesHandler = logtailreplay.NewChangesHandler
NewPartitionStateChangesHandler is the function used to create a ChangeHandler from the partition state. It is a variable so tests can stub it.
var RequestSnapshotRead = func(ctx context.Context, tbl *txnTable, snapshot *types.TS) (resp any, err error) { whichTN := func(string) ([]uint64, error) { return nil, nil } payload := func(tnShardID uint64, parameter string, proc *process.Process) ([]byte, error) { req := cmd_util.SnapshotReadReq{} ts := snapshot.ToTimestamp() req.Snapshot = &ts return req.MarshalBinary() } responseUnmarshaler := func(payload []byte) (any, error) { checkpoints := &cmd_util.SnapshotReadResp{} if err = checkpoints.UnmarshalBinary(payload); err != nil { return nil, err } return checkpoints, nil } tableProc := tbl.proc.Load() proc := process.NewTopProcess(ctx, tableProc.GetMPool(), tableProc.Base.TxnClient, tableProc.GetTxnOperator(), tableProc.Base.FileService, tableProc.Base.LockService, tableProc.Base.QueryClient, tableProc.Base.Hakeeper, tableProc.Base.UdfService, tableProc.Base.Aicm, tableProc.Base.TaskService, ) handler := ctl.GetTNHandlerFunc(api.OpCode_OpSnapshotRead, whichTN, payload, responseUnmarshaler) result, err := handler(proc, "DN", "", ctl.MoCtlTNCmdSender) sleep, sarg, exist := fault.TriggerFault("snapshot_read_timeout") if exist { time.Sleep(time.Duration(sleep) * time.Second) return nil, moerr.NewInternalError(ctx, sarg) } if moerr.IsMoErrCode(err, moerr.ErrNotSupported) { return nil, moerr.NewNotSupportedNoCtx("current tn version not supported `snapshot read`") } if err != nil { return nil, err } if len(result.Data.([]any)) == 0 { return cmd_util.SnapshotReadResp{Succeed: false}, nil } return result.Data.([]any)[0], nil }
var TableStatsName = [TableStatsCnt]string{
"table_size",
"table_rows",
"tobject_cnt",
"dobject_cnt",
"tblock_cnt",
"dblock_cnt",
}
Functions ¶
func BuildLocalDataSource ¶
func BuildLocalDataSource( ctx context.Context, rel engine.Relation, ranges engine.RelData, txnOffset int, ) (source engine.DataSource, err error)
for ut
func CheckTxnIsValid ¶ added in v1.2.1
func CheckTxnIsValid(txnOp client.TxnOperator) (err error)
func CollectAndCalculateStats ¶
func CollectAndCalculateStats(ctx context.Context, req *updateStatsRequest, executor ConcurrentExecutor) (float64, error)
CollectAndCalculateStats is the main function to calculate and update the stats for scan node. Returns the actual sampling ratio used (sampledObjects / totalObjects).
func ConstructObjStatsByLoadObjMeta ¶ added in v1.1.0
func ConstructObjStatsByLoadObjMeta( ctx context.Context, metaLoc objectio.Location, fs fileservice.FileService, ) (stats objectio.ObjectStats, dataMeta objectio.ObjectDataMeta, err error)
func DefaultNewRpcStreamToTnLogTailService ¶
func DefaultNewRpcStreamToTnLogTailService( ctx context.Context, sid string, serviceAddr string, rpcClient morpc.RPCClient, ) (morpc.RPCClient, morpc.Stream, error)
XXX generate a rpc client and new a stream. we should hide these code into service's NewClient method next day.
func ForeachCommittedObjects ¶ added in v1.2.0
func ForeachCommittedObjects( createObjs map[objectio.ObjectNameShort]struct{}, delObjs map[objectio.ObjectNameShort]struct{}, p *logtailreplay.PartitionState, onObj func(info objectio.ObjectEntry) error) (err error)
func ForeachSnapshotObjects ¶ added in v1.1.0
func ForeachSnapshotObjects( ts timestamp.Timestamp, onObject func(obj objectio.ObjectEntry, isCommitted bool) error, tableSnapshot *logtailreplay.PartitionState, extraCommitted []objectio.ObjectStats, uncommitted ...objectio.ObjectStats, ) (err error)
func ForeachTombstoneObject ¶
func ForeachTombstoneObject( ts types.TS, onTombstone func(tombstone objectio.ObjectEntry) (next bool, err error), pState *logtailreplay.PartitionState, ) error
func ForeachVisibleObjects ¶
func ForeachVisibleObjects( state *logtailreplay.PartitionState, ts types.TS, fn func(obj objectio.ObjectEntry) error, executor ConcurrentExecutor, visitTombstone bool, ) (err error)
func GetChangedTableList ¶
func GetChangedTableList( ctx context.Context, service string, eng engine.Engine, accs []uint64, dbs []uint64, tbls []uint64, ts []timestamp.Timestamp, to *types.TS, minTS *types.TS, typ cmd_util.ChangedListType, forEachTable func( accountID int64, databaseID int64, tableID int64, tableName string, dbName string, relKind string, pkSequence int, snapshot types.TS, ), handleFn func( ctx context.Context, meta txn.TxnMeta, req *cmd_util.GetChangedTableListReq, resp *cmd_util.GetChangedTableListResp, ) (func(), error), ) (err error)
func GetMOTableStatsExecutor ¶
func GetPartitionStateStart ¶
func HandleShardingReadApproxObjectsNum ¶
func HandleShardingReadApproxObjectsNum( ctx context.Context, shard shard.TableShard, engine engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadApproxObjectsNum handles sharding read ApproxObjectsNum
func HandleShardingReadBuildReader ¶
func HandleShardingReadBuildReader( ctx context.Context, shard shard.TableShard, e engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadReader handles sharding read Reader
func HandleShardingReadClose ¶
func HandleShardingReadGetColumMetadataScanInfo ¶
func HandleShardingReadGetColumMetadataScanInfo( ctx context.Context, shard shard.TableShard, engine engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadGetColumMetadataScanInfo handles sharding read GetColumMetadataScanInfo
func HandleShardingReadMergeObjects ¶
func HandleShardingReadMergeObjects( ctx context.Context, shard shard.TableShard, engine engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadMergeObjects handles sharding read MergeObjects
func HandleShardingReadNext ¶
func HandleShardingReadPrimaryKeysMayBeModified ¶
func HandleShardingReadPrimaryKeysMayBeModified( ctx context.Context, shard shard.TableShard, engine engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadPrimaryKeysMayBeModified handles sharding read PrimaryKeysMayBeModified
func HandleShardingReadRanges ¶
func HandleShardingReadRanges( ctx context.Context, shard shard.TableShard, eng engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadRanges handles sharding read Ranges
func HandleShardingReadRows ¶
func HandleShardingReadRows( ctx context.Context, shard shard.TableShard, engine engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadRows handles sharding read rows
func HandleShardingReadSize ¶
func HandleShardingReadSize( ctx context.Context, shard shard.TableShard, engine engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadSize handles sharding read size
func HandleShardingReadStatus ¶
func HandleShardingReadStatus( ctx context.Context, shard shard.TableShard, engine engine.Engine, param shard.ReadParam, ts timestamp.Timestamp, buffer *morpc.Buffer, ) ([]byte, error)
HandleShardingReadStatus handles sharding read status
func LinearSearchOffsetByValFactory ¶ added in v1.2.0
func ListTnService ¶ added in v1.1.0
ListTnService gets all tn service in the cluster
func MockTableDelegate ¶
func MockTableDelegate( tableDelegate engine.Relation, service shardservice.ShardService, ) (engine.Relation, error)
func NewTableMetaReader ¶
func ScanSnapshotWithCurrentRanges ¶
func ScanSnapshotWithCurrentRanges( ctx context.Context, caller string, rel engine.Relation, relData engine.RelData, snapshotTS types.TS, attrs []string, colTypes []types.Type, filterExpr *plan.Expr, scanParallelism int, mp *mpool.MPool, onBatch func(*batch.Batch) error, ) error
ScanSnapshotWithCurrentRanges reads rows at snapshotTS by reusing the current relation handle and its current-view ranges.
Snapshot scan reuses current-view disk ranges, but materializes the latest committed in-memory rows separately so reader fallback does not need to lazily consult historical pState state during scan execution.
Serial path uses a hybrid source that emits committed in-memory rows first, then reads persisted blocks through RemoteDataSource. Parallel path emits the same committed in-memory rows once, then scans persisted shards concurrently.
Types ¶
type CCPRTxnCache ¶
type CCPRTxnCache struct {
// contains filtered or unexported fields
}
CCPRTxnCache is a cache for tracking CCPR (Cross-Cluster Publication Replication) objects and their associated transactions. It maintains a mapping from object names to transaction IDs.
Thread-safety: All methods are thread-safe and use mutex for synchronization.
Lifecycle of an entry:
- WriteObject: creates entry with isWriting=true (if new file) or appends txnID
- OnFileWritten: clears isWriting; if already committed, deletes the entry
- OnTxnCommit: marks committed=true; if not isWriting, deletes the entry
- OnTxnRollback: removes txnID; if last txnID and not committed, GCs the file
- OnTxnUnknownResult: removes cache tracking without deleting the file
func NewCCPRTxnCache ¶
func NewCCPRTxnCache(gcPool *ants.Pool, fs fileservice.FileService) *CCPRTxnCache
NewCCPRTxnCache creates a new CCPRTxnCache instance
func (*CCPRTxnCache) OnFileWritten ¶
func (c *CCPRTxnCache) OnFileWritten(objectName string)
OnFileWritten is called after the file has been successfully written to fileservice. It clears the isWriting flag. If the entry is already committed, deletes the entry since the file is now safely persisted and no longer needs cache tracking.
func (*CCPRTxnCache) OnTxnCommit ¶
func (c *CCPRTxnCache) OnTxnCommit(txnID []byte)
OnTxnCommit is called when a transaction commits successfully. It marks the entry as committed and removes the entire entry if the file has already been written (!isWriting). If still writing, the entry stays until OnFileWritten cleans it up.
func (*CCPRTxnCache) OnTxnRollback ¶
func (c *CCPRTxnCache) OnTxnRollback(txnID []byte)
OnTxnRollback is called when a transaction rolls back. It removes the txnID from all associated object entries. If an object entry has no more txnIDs and was never committed, the file is GC'd. If the entry was committed (by another txn), the file is kept.
func (*CCPRTxnCache) OnTxnUnknownResult ¶
func (c *CCPRTxnCache) OnTxnUnknownResult(txnID []byte)
OnTxnUnknownResult is called when the transaction commit result is unknown. The object may already be committed, so this path must not GC object files. It removes cache tracking for affected objects so later rollback cleanup cannot delete a possibly-committed object through stale CCPR references.
func (*CCPRTxnCache) WriteObject ¶
func (c *CCPRTxnCache) WriteObject(ctx context.Context, objectName string, txnID []byte) (isNewFile bool, err error)
WriteObject checks if an object needs to be written and registers it with the given transaction ID. This method DOES NOT write the file - it only checks and registers in the cache. The caller is responsible for writing the file when isNewFile is true.
After the caller writes the file, it should call OnFileWritten to complete the registration.
Returns:
- isNewFile: true if file needs to be written, false if file already exists or is being written
- error: error if operation failed
type CheckpointChangesHandle ¶
type CheckpointChangesHandle struct {
// contains filtered or unexported fields
}
func (*CheckpointChangesHandle) Close ¶
func (h *CheckpointChangesHandle) Close() error
type CloneTxnCache ¶
type CloneTxnCache struct {
// contains filtered or unexported fields
}
func (CloneTxnCache) AddSharedFile ¶
func (ctc CloneTxnCache) AddSharedFile(txnId []byte, name string)
func (CloneTxnCache) AddTxn ¶
func (ctc CloneTxnCache) AddTxn(txnId []byte, snapshot int64)
func (CloneTxnCache) AddTxnLocalSharedFile ¶
func (ctc CloneTxnCache) AddTxnLocalSharedFile(txnId []byte, name string)
func (CloneTxnCache) DeleteTxn ¶
func (ctc CloneTxnCache) DeleteTxn(txnId []byte)
func (CloneTxnCache) IsSharedFile ¶
func (ctc CloneTxnCache) IsSharedFile(txnId []byte, name string) bool
func (CloneTxnCache) IsTxnLocalSharedFile ¶
func (ctc CloneTxnCache) IsTxnLocalSharedFile(txnId []byte, name string) bool
func (CloneTxnCache) RemoveTxnLocalSharedFile ¶
func (ctc CloneTxnCache) RemoveTxnLocalSharedFile(txnId []byte, name string)
type CombinedRelData ¶
type CombinedRelData struct {
// contains filtered or unexported fields
}
func (*CombinedRelData) AppendBlockInfo ¶
func (r *CombinedRelData) AppendBlockInfo(blk *objectio.BlockInfo)
func (*CombinedRelData) AppendBlockInfoSlice ¶
func (r *CombinedRelData) AppendBlockInfoSlice(objectio.BlockInfoSlice)
func (*CombinedRelData) AppendShardID ¶
func (r *CombinedRelData) AppendShardID(id uint64)
func (*CombinedRelData) AttachTombstones ¶
func (r *CombinedRelData) AttachTombstones(tombstones engine.Tombstoner) error
func (*CombinedRelData) BuildEmptyRelData ¶
func (r *CombinedRelData) BuildEmptyRelData(preAllocSize int) engine.RelData
func (*CombinedRelData) DataCnt ¶
func (r *CombinedRelData) DataCnt() int
func (*CombinedRelData) DataSlice ¶
func (r *CombinedRelData) DataSlice(begin, end int) engine.RelData
func (*CombinedRelData) GetBlockInfo ¶
func (r *CombinedRelData) GetBlockInfo(i int) objectio.BlockInfo
func (*CombinedRelData) GetBlockInfoSlice ¶
func (r *CombinedRelData) GetBlockInfoSlice() objectio.BlockInfoSlice
func (*CombinedRelData) GetShardID ¶
func (r *CombinedRelData) GetShardID(i int) uint64
func (*CombinedRelData) GetShardIDList ¶
func (r *CombinedRelData) GetShardIDList() []uint64
func (*CombinedRelData) GetTombstones ¶
func (r *CombinedRelData) GetTombstones() engine.Tombstoner
func (*CombinedRelData) GetType ¶
func (r *CombinedRelData) GetType() engine.RelDataType
func (*CombinedRelData) MarshalBinary ¶
func (r *CombinedRelData) MarshalBinary() ([]byte, error)
func (*CombinedRelData) SetBlockInfo ¶
func (r *CombinedRelData) SetBlockInfo(i int, blk *objectio.BlockInfo)
func (*CombinedRelData) SetShardID ¶
func (r *CombinedRelData) SetShardID(i int, id uint64)
func (*CombinedRelData) String ¶
func (r *CombinedRelData) String() string
func (*CombinedRelData) UnmarshalBinary ¶
func (r *CombinedRelData) UnmarshalBinary(buf []byte) error
type ConcurrentExecutor ¶ added in v1.2.2
type ConcurrentExecutor interface {
// AppendTask append the concurrent task to the exuecutor.
AppendTask(concurrentTask)
// Run starts receive task to execute.
Run(context.Context)
// GetConcurrency returns the concurrency of this executor.
GetConcurrency() int
}
ConcurrentExecutor is an interface that runs tasks concurrently.
type Engine ¶
func New ¶
func New( ctx context.Context, service string, mp *mpool.MPool, fs fileservice.FileService, cli client.TxnClient, hakeeper logservice.CNHAKeeperClient, keyRouter client2.KeyRouter[pb.StatsInfoKey], updateWorkerFactor int, options ...EngineOptions, ) *Engine
func (*Engine) AllocateIDByKey ¶ added in v0.8.0
func (*Engine) BuildBlockReaders ¶
func (*Engine) FS ¶
func (e *Engine) FS() fileservice.FileService
func (*Engine) GCCatalogCache ¶
GCCatalogCache implements engine.CatalogCacheGCer.
func (*Engine) GetCCPRTxnCache ¶
func (e *Engine) GetCCPRTxnCache() *CCPRTxnCache
GetCCPRTxnCache returns the CCPR transaction cache
func (*Engine) GetGlobalStats ¶
func (e *Engine) GetGlobalStats() *GlobalStats
GetGlobalStats returns the GlobalStats instance
func (*Engine) GetLatestCatalogCache ¶
func (e *Engine) GetLatestCatalogCache() *cache.CatalogCache
func (*Engine) GetMessageCenter ¶
func (*Engine) GetNameById ¶ added in v0.7.0
func (*Engine) GetOrCreateLatestPart ¶
func (*Engine) GetRelationById ¶ added in v0.7.0
func (*Engine) GetService ¶
func (*Engine) GetTNServices ¶
func (*Engine) HandleMoTableStatsCtl ¶
func (*Engine) InitLogTailPushModel ¶ added in v0.8.0
func (*Engine) LatestLogtailAppliedTime ¶
func (*Engine) LaunchMTSTasksForUT ¶
func (d *Engine) LaunchMTSTasksForUT()
func (*Engine) LazyLoadLatestCkp ¶
func (*Engine) LogDynamicCtx ¶
func (d *Engine) LogDynamicCtx() string
func (*Engine) MTSTableRows ¶
func (*Engine) MTSTableSize ¶
func (*Engine) NotifyCleanDeletes ¶
func (d *Engine) NotifyCleanDeletes()
func (*Engine) NotifyInsertNewTable ¶
func (d *Engine) NotifyInsertNewTable()
func (*Engine) NotifyUpdateForgotten ¶
func (d *Engine) NotifyUpdateForgotten()
func (*Engine) PackerPool ¶
func (e *Engine) PackerPool() *fileservice.Pool[*types.Packer]
func (*Engine) PrefetchTableMeta ¶
return true if the prefetch is received return false if the prefetch is not rejected
func (*Engine) PushClient ¶ added in v1.2.0
func (e *Engine) PushClient() *PushClient
func (*Engine) QueryTableStats ¶
func (*Engine) QueryTableStatsByAccounts ¶
func (*Engine) QueryTableStatsByDatabase ¶
func (*Engine) QueryTableStatsByTable ¶
func (*Engine) ReleaseQuota ¶
func (*Engine) ResetGCWorkerPool ¶
func (*Engine) RunGCScheduler ¶
RunGCScheduler runs all GC tasks in a single goroutine with different intervals
func (*Engine) SetService ¶
func (*Engine) SetWorkspaceThreshold ¶
func (e *Engine) SetWorkspaceThreshold(commitThreshold, writeThreshold uint64) (commit, write uint64)
SetWorkspaceThreshold updates the commit and write workspace thresholds (in MB). Non-zero values override the current thresholds, while zero keeps them unchanged. Returns the previous thresholds (in MB).
type EngineOptions ¶
type EngineOptions func(*Engine)
func WithCNTransferTxnLifespanThreshold ¶
func WithCNTransferTxnLifespanThreshold(th time.Duration) EngineOptions
func WithCommitWorkspaceThreshold ¶
func WithCommitWorkspaceThreshold(th uint64) EngineOptions
func WithExtraWorkspaceThreshold ¶
func WithExtraWorkspaceThreshold(th uint64) EngineOptions
func WithExtraWorkspaceThresholdQuota ¶
func WithExtraWorkspaceThresholdQuota(quota uint64) EngineOptions
func WithInsertEntryMaxCount ¶
func WithInsertEntryMaxCount(th int) EngineOptions
func WithMoServerStateChecker ¶
func WithMoServerStateChecker(checker func() bool) EngineOptions
func WithMoTableStatsConf ¶
func WithMoTableStatsConf(conf MoTableStatsConfig) EngineOptions
func WithPrefetchOnSubscribed ¶
func WithPrefetchOnSubscribed(th []string) EngineOptions
func WithSQLExecFunc ¶
func WithSQLExecFunc(f func() ie.InternalExecutor) EngineOptions
func WithWriteWorkspaceThreshold ¶
func WithWriteWorkspaceThreshold(th uint64) EngineOptions
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry represents a delete/insert
func (*Entry) DatabaseId ¶
type GlobalStats ¶ added in v1.2.0
type GlobalStats struct {
// KeyRouter is the router to decides which node should send to.
KeyRouter client.KeyRouter[pb.StatsInfoKey]
// contains filtered or unexported fields
}
func NewGlobalStats ¶ added in v1.2.0
func NewGlobalStats( ctx context.Context, e *Engine, keyRouter client.KeyRouter[pb.StatsInfoKey], opts ...GlobalStatsOption, ) *GlobalStats
func (*GlobalStats) Get ¶ added in v1.2.0
func (gs *GlobalStats) Get(ctx context.Context, key pb.StatsInfoKey, sync bool) *pb.StatsInfo
func (*GlobalStats) GetBaseObjectCnt ¶
func (gs *GlobalStats) GetBaseObjectCnt(key pb.StatsInfoKey) int64
func (*GlobalStats) GetSamplingRatio ¶
func (gs *GlobalStats) GetSamplingRatio(key pb.StatsInfoKey) float64
GetSamplingRatio returns the sampling ratio used in the last stats update for the given key. Returns 0 if no update record exists.
func (*GlobalStats) PatchStats ¶
func (gs *GlobalStats) PatchStats(key pb.StatsInfoKey, patch *PatchArgs) error
PatchStats partially updates the stats for the given key
func (*GlobalStats) PrefetchTableMeta ¶
func (gs *GlobalStats) PrefetchTableMeta(ctx context.Context, key pb.StatsInfoKey) bool
func (*GlobalStats) RefreshWithMode ¶
func (gs *GlobalStats) RefreshWithMode(ctx context.Context, key pb.StatsInfoKey, samplingMode string) error
RefreshWithMode triggers a stats refresh with the specified sampling mode
func (*GlobalStats) RemoveTid ¶ added in v1.2.2
func (gs *GlobalStats) RemoveTid(tableID uint64)
RemoveTid removes all statsInfoMap entries for the given table ID. Called from cleanMemoryTableWithTable (1+ hour after unsubscribe/drop) to prevent unbounded map growth. Safe because no queries target a table that has been unsubscribed for over an hour.
type GlobalStatsConfig ¶ added in v1.2.0
type GlobalStatsConfig struct {
LogtailUpdateStatsThreshold int
}
type GlobalStatsOption ¶ added in v1.2.0
type GlobalStatsOption func(s *GlobalStats)
func WithApproxObjectNumUpdater ¶
func WithApproxObjectNumUpdater(f func() int64) GlobalStatsOption
WithApproxObjectNumUpdater set the update function to update approx object num.
func WithUpdateWorkerFactor ¶ added in v1.2.2
func WithUpdateWorkerFactor(f int) GlobalStatsOption
WithUpdateWorkerFactor set the update worker factor.
type IDGenerator ¶
type ItemEntry ¶
type ItemEntry struct {
// contains filtered or unexported fields
}
ItemEntry represents an entry in the items BTree, sorted by objectName
type LocalDisttaeDataSource ¶
type LocalDisttaeDataSource struct {
OrderBy []*plan.OrderBySpec
Limit uint64
// contains filtered or unexported fields
}
func NewLocalDataSource ¶
func NewLocalDataSource( ctx context.Context, table *txnTable, txnOffset int, pState *logtailreplay.PartitionState, rangesSlice objectio.BlockInfoSlice, extraTombstones engine.Tombstoner, skipReadMem bool, policy engine.TombstoneApplyPolicy, category engine.DataSourceType, ) (source *LocalDisttaeDataSource, err error)
func (*LocalDisttaeDataSource) ApplyTombstones ¶
func (ls *LocalDisttaeDataSource) ApplyTombstones( ctx context.Context, bid *objectio.Blockid, rowsOffset []int64, dynamicPolicy engine.TombstoneApplyPolicy, ) ([]int64, error)
ApplyTombstones check if any deletes exist in
- unCommittedInmemDeletes: a. workspace writes b. flushed to s3 c. raw rowId offset deletes (not flush yet)
- committedInmemDeletes
- committedPersistedTombstone
func (*LocalDisttaeDataSource) Close ¶
func (ls *LocalDisttaeDataSource) Close()
func (*LocalDisttaeDataSource) GetOrderBy ¶
func (ls *LocalDisttaeDataSource) GetOrderBy() []*plan.OrderBySpec
func (*LocalDisttaeDataSource) GetTombstones ¶
func (*LocalDisttaeDataSource) SetFilterZM ¶
func (ls *LocalDisttaeDataSource) SetFilterZM(zm objectio.ZoneMap)
func (*LocalDisttaeDataSource) SetOrderBy ¶
func (ls *LocalDisttaeDataSource) SetOrderBy(orderby []*plan.OrderBySpec)
func (*LocalDisttaeDataSource) String ¶
func (ls *LocalDisttaeDataSource) String() string
type MoTableStatsConfig ¶
type MoTableStatsConfig struct {
UpdateDuration time.Duration `toml:"update-duration"`
ForceUpdate bool `toml:"force-update"`
GetTableListLimit int `toml:"get-table-list-limit"`
StatsUsingOldImpl bool `toml:"stats-using-old-impl"`
DisableStatsTask bool `toml:"disable-stats-task"`
CorrectionDuration time.Duration `toml:"correction-duration"`
}
type PartitionChangesHandle ¶
type PartitionChangesHandle struct {
// contains filtered or unexported fields
}
func (*PartitionChangesHandle) Close ¶
func (h *PartitionChangesHandle) Close() error
type PatchArgs ¶
type PatchArgs struct {
// Table-level stats
TableCnt *float64 `json:"table_cnt,omitempty"`
BlockNumber *int64 `json:"block_number,omitempty"`
AccurateObjectNumber *int64 `json:"accurate_object_number,omitempty"`
// Column-level stats (merge mode)
NdvMap map[string]float64 `json:"ndv_map,omitempty"`
MinValMap map[string]float64 `json:"min_val_map,omitempty"`
MaxValMap map[string]float64 `json:"max_val_map,omitempty"`
NullCntMap map[string]uint64 `json:"null_cnt_map,omitempty"`
SizeMap map[string]uint64 `json:"size_map,omitempty"`
// ShuffleRange partial updates (fine-grained control per column)
// Each column can have its Overlap/Uniform/Result fields updated independently
ShuffleRangeMap map[string]*ShuffleRangePartialUpdate `json:"shuffle_range_map,omitempty"`
}
PatchArgs defines arguments for patch command
type PushClient ¶ added in v1.2.0
type PushClient struct {
LogtailRPCClientFactory func(context.Context, string, string, morpc.RPCClient) (morpc.RPCClient, morpc.Stream, error)
// contains filtered or unexported fields
}
PushClient is a structure responsible for all operations related to the log tail push model. It provides the following methods:
----------------------------------------------------------------------------------------------------- 1. checkTxnTimeIsLegal : block the process until we have received enough log tail (T_log >= T_txn) 2. TryToSubscribeTable : block the process until we subscribed a table succeed. 3. subscribeTable : send a table subscribe request to service. 4. subSysTables : subscribe mo_databases, mo_tables, mo_columns 5. receiveTableLogTailContinuously : start (1 + consumerNumber) routine to receive log tail from service. Watch out for the following points: 1. if we want to lock both subscriber and subscribed, we should lock subscriber first. -----------------------------------------------------------------------------------------------------
func (*PushClient) Disconnect ¶
func (c *PushClient) Disconnect() error
func (*PushClient) GetState ¶ added in v1.2.0
func (c *PushClient) GetState() State
func (*PushClient) IsSubscribed ¶
func (c *PushClient) IsSubscribed(tblId uint64) bool
func (*PushClient) IsSubscriberReady ¶
func (c *PushClient) IsSubscriberReady() bool
func (*PushClient) LatestLogtailAppliedTime ¶
func (c *PushClient) LatestLogtailAppliedTime() timestamp.Timestamp
func (*PushClient) SetReconnectHandler ¶
func (c *PushClient) SetReconnectHandler(handler func())
func (*PushClient) SetSubscribeState ¶
func (c *PushClient) SetSubscribeState(dbId, tblId uint64, state SubscribeState)
Only used for ut
func (*PushClient) TryGC ¶
func (c *PushClient) TryGC(ctx context.Context)
TryGC checks if ready and runs GC for PushClient resources (unused tables)
func (*PushClient) TryToSubscribeTable ¶ added in v1.2.0
func (c *PushClient) TryToSubscribeTable( ctx context.Context, accId, dbId, tblId uint64, dbName, tblName string, ) (err error)
TryToSubscribeTable subscribe a table and block until subscribe succeed.
func (*PushClient) UnsubscribeTable ¶ added in v1.2.0
func (c *PushClient) UnsubscribeTable(ctx context.Context, accId, dbID, tbID uint64) error
UnsubscribeTable implements the LogtailEngine interface.
type ShuffleRangePartialUpdate ¶
type ShuffleRangePartialUpdate struct {
Overlap *float64 `json:"overlap,omitempty"`
Uniform *float64 `json:"uniform,omitempty"`
Result []float64 `json:"result,omitempty"`
}
ShuffleRangePartialUpdate contains fields that can be independently updated in ShuffleRange
type SnapshotGCConfig ¶
type SnapshotGCConfig struct {
Enabled bool // Whether snapshot GC is enabled
GCInterval time.Duration // Interval between GC runs
MaxAge time.Duration // Max age for inactive snapshots
MaxSnapshotsPerTable int // Max snapshots per table
MaxTotalSnapshots int // Max total snapshots across all tables
}
SnapshotGCConfig holds configuration for snapshot GC
func DefaultSnapshotGCConfig ¶
func DefaultSnapshotGCConfig() SnapshotGCConfig
DefaultSnapshotGCConfig returns the default configuration
type SnapshotGCState ¶
type SnapshotGCState struct {
// contains filtered or unexported fields
}
SnapshotGCState holds the runtime state for snapshot GC
type SnapshotManager ¶
SnapshotManager manages all tracked partitions across all tables
func NewSnapshotManager ¶
func NewSnapshotManager() *SnapshotManager
NewSnapshotManager creates a new SnapshotManager
func (*SnapshotManager) Add ¶
func (sm *SnapshotManager) Add( dbID, tableID uint64, partition *logtailreplay.Partition, tableName string, ts types.TS, ) *logtailreplay.PartitionState
Add adds a new partition to the manager for a table
func (*SnapshotManager) Find ¶
func (sm *SnapshotManager) Find(dbID, tableID uint64, ts types.TS) *logtailreplay.PartitionState
Find searches for a snapshot that can serve the given timestamp for a table
func (*SnapshotManager) GetConfig ¶
func (sm *SnapshotManager) GetConfig() SnapshotGCConfig
GetConfig returns a copy of the configuration
func (*SnapshotManager) GetMetrics ¶
func (sm *SnapshotManager) GetMetrics() *SnapshotMetrics
GetMetrics returns a pointer to current metrics
func (*SnapshotManager) GetOrCreate ¶
func (sm *SnapshotManager) GetOrCreate(dbID, tableID uint64) *TrackedPartitions
GetOrCreate gets or creates a TrackedPartitions for the given table
func (*SnapshotManager) Init ¶
func (sm *SnapshotManager) Init()
Init initializes the snapshot manager with configuration
func (*SnapshotManager) MaybeStartGC ¶
func (sm *SnapshotManager) MaybeStartGC()
MaybeStartGC checks if GC should run and starts it if needed
func (*SnapshotManager) RunGC ¶
func (sm *SnapshotManager) RunGC()
RunGC performs garbage collection on all tracked partitions
type SnapshotMetrics ¶
type SnapshotMetrics struct {
TotalSnapshots atomic.Int64 // Current total snapshots
TotalTables atomic.Int64 // Current tables with snapshots
GCRuns atomic.Int64 // Total GC runs
SnapshotsGCed atomic.Int64 // Total snapshots GCed
LastGCDuration atomic.Int64 // Last GC duration in nanoseconds
SnapshotHits atomic.Int64 // Snapshot cache hits (reuse)
SnapshotMisses atomic.Int64 // Snapshot cache misses (create)
SnapshotCreates atomic.Int64 // Total snapshots created
LRUEvictions atomic.Int64 // Evictions due to count limit
AgeEvictions atomic.Int64 // Evictions due to age limit
}
SnapshotMetrics holds metrics for snapshot management
type State ¶ added in v1.2.0
type State struct {
LatestTS timestamp.Timestamp
SubTables map[uint64]SubTableStatus
}
type SubTableStatus ¶ added in v1.2.0
type SubTableStatus struct {
DBID uint64
SubState SubscribeState
LatestTime time.Time
}
SubTableStatus is used for external API compatibility (e.g., GetState).
type SubscribeState ¶ added in v1.2.1
type SubscribeState int32
const ( InvalidSubState SubscribeState = iota Subscribing SubRspReceived Subscribed Unsubscribing Unsubscribed SubRspTableNotExist FakeLogtailServerAddress = "fake address for ut" )
type TableMetaReader ¶
type TableMetaReader struct {
// contains filtered or unexported fields
}
func (*TableMetaReader) Close ¶
func (r *TableMetaReader) Close() error
func (*TableMetaReader) GetOrderBy ¶
func (r *TableMetaReader) GetOrderBy() []*plan.OrderBySpec
func (*TableMetaReader) GetTableDef ¶
func (r *TableMetaReader) GetTableDef() *plan.TableDef
func (*TableMetaReader) GetTxnInfo ¶
func (r *TableMetaReader) GetTxnInfo() string
func (*TableMetaReader) SetFilterZM ¶
func (r *TableMetaReader) SetFilterZM(zoneMap objectio.ZoneMap)
func (*TableMetaReader) SetIndexParam ¶
func (r *TableMetaReader) SetIndexParam(param *plan.IndexReaderParam)
func (*TableMetaReader) SetOrderBy ¶
func (r *TableMetaReader) SetOrderBy(specs []*plan.OrderBySpec)
type TrackedPartition ¶
type TrackedPartition struct {
// contains filtered or unexported fields
}
TrackedPartition wraps a partition with access tracking information
func NewTrackedPartition ¶
func NewTrackedPartition(partition *logtailreplay.Partition) *TrackedPartition
NewTrackedPartition creates a new TrackedPartition
func (*TrackedPartition) GetAge ¶
func (tp *TrackedPartition) GetAge() time.Duration
GetAge returns the age since last access
func (*TrackedPartition) GetCreateTime ¶
func (tp *TrackedPartition) GetCreateTime() time.Time
GetCreateTime returns the creation time
func (*TrackedPartition) GetLastAccessTime ¶
func (tp *TrackedPartition) GetLastAccessTime() time.Time
GetLastAccessTime returns the last access time
func (*TrackedPartition) GetPartition ¶
func (tp *TrackedPartition) GetPartition() *logtailreplay.Partition
GetPartition returns the underlying partition and updates access time
type TrackedPartitions ¶
TrackedPartitions manages a collection of tracked partitions for a table
func NewTrackedPartitions ¶
func NewTrackedPartitions(dbID, tableID uint64, metrics *SnapshotMetrics) *TrackedPartitions
NewTrackedPartitions creates a new TrackedPartitions manager
func (*TrackedPartitions) Add ¶
func (tp *TrackedPartitions) Add( partition *logtailreplay.Partition, tableName string, ts types.TS, maxCount int, ) *logtailreplay.PartitionState
Add adds a new tracked partition, enforcing the maximum count limit with LRU eviction Returns the partition state of the added partition
func (*TrackedPartitions) Count ¶
func (tp *TrackedPartitions) Count() int
Count returns the current number of tracked partitions
func (*TrackedPartitions) Find ¶
func (tp *TrackedPartitions) Find(ts types.TS) *logtailreplay.PartitionState
Find searches for a partition that can serve the given timestamp Returns the partition state if found, or nil if not found Automatically updates access time and metrics
type Transaction ¶
Transaction represents a transaction
func NewTxnWorkSpace ¶
func NewTxnWorkSpace(eng *Engine, proc *process.Process) *Transaction
func (*Transaction) Adjust ¶ added in v1.0.0
func (txn *Transaction) Adjust(writeOffset uint64) error
Adjust adjust writes order after the current statement finished.
func (*Transaction) ApproximateInMemInsertSize ¶
func (txn *Transaction) ApproximateInMemInsertSize() uint64
ApproximateInMemInsertSize returns the approximate total size of in-memory insert entries in the workspace. Intended for testing and diagnostics.
func (*Transaction) BindTxnOp ¶ added in v1.2.0
func (txn *Transaction) BindTxnOp(op client.TxnOperator)
func (*Transaction) CloneSnapshotWS ¶ added in v1.2.0
func (txn *Transaction) CloneSnapshotWS() client.Workspace
func (*Transaction) Commit ¶ added in v0.8.0
func (txn *Transaction) Commit(ctx context.Context) (reqs []txn.TxnRequest, err error)
func (*Transaction) EndStatement ¶ added in v1.0.0
func (txn *Transaction) EndStatement()
func (*Transaction) FinalizeCommit ¶
func (txn *Transaction) FinalizeCommit(context.Context)
func (*Transaction) FinalizeCommitWithUnknownResult ¶
func (txn *Transaction) FinalizeCommitWithUnknownResult(context.Context)
func (*Transaction) ForEachTableWrites ¶
func (txn *Transaction) ForEachTableWrites(databaseId uint64, tableId uint64, offset int, f func(Entry))
func (*Transaction) GCObjsByIdxRange ¶
func (txn *Transaction) GCObjsByIdxRange(start, end int) (err error)
[start, end]
func (*Transaction) GCObjsByStats ¶
func (txn *Transaction) GCObjsByStats(sl ...objectio.ObjectStats) (err error)
func (*Transaction) GetCCPRTaskID ¶
func (txn *Transaction) GetCCPRTaskID() string
GetCCPRTaskID returns the CCPR task ID for this transaction. Returns empty string if no task ID is set.
func (*Transaction) GetHaveDDL ¶ added in v1.2.2
func (txn *Transaction) GetHaveDDL() bool
func (*Transaction) GetProc ¶
func (txn *Transaction) GetProc() *process.Process
func (*Transaction) GetSQLCount ¶ added in v1.0.0
func (txn *Transaction) GetSQLCount() uint64
func (*Transaction) GetSnapshotWriteOffset ¶ added in v1.1.2
func (txn *Transaction) GetSnapshotWriteOffset() int
func (*Transaction) GetSyncProtectionJobID ¶
func (txn *Transaction) GetSyncProtectionJobID() string
GetSyncProtectionJobID returns the sync protection job ID for this transaction. Returns empty string if no job ID is set.
func (*Transaction) IncrSQLCount ¶ added in v1.0.0
func (txn *Transaction) IncrSQLCount()
func (*Transaction) IncrStatementID ¶ added in v0.8.0
func (txn *Transaction) IncrStatementID(ctx context.Context, commit bool) error
func (*Transaction) IsCCPRTxn ¶
func (txn *Transaction) IsCCPRTxn() bool
IsCCPRTxn returns true if this transaction is a CCPR transaction.
func (*Transaction) PPString ¶
func (txn *Transaction) PPString() string
func (*Transaction) ReadOnly ¶
func (txn *Transaction) ReadOnly() bool
detecting whether a transaction is a read-only transaction
func (*Transaction) Readonly ¶
func (txn *Transaction) Readonly() bool
func (*Transaction) Rollback ¶ added in v0.8.0
func (txn *Transaction) Rollback(ctx context.Context) error
func (*Transaction) RollbackLastStatement ¶ added in v0.8.0
func (txn *Transaction) RollbackLastStatement(ctx context.Context) error
func (*Transaction) SetCCPRTaskID ¶
func (txn *Transaction) SetCCPRTaskID(taskID string)
SetCCPRTaskID sets the CCPR task ID for this transaction. When a CCPR task ID is set, the transaction can bypass shared object read-only checks.
func (*Transaction) SetCCPRTxn ¶
func (txn *Transaction) SetCCPRTxn()
SetCCPRTxn marks this transaction as a CCPR transaction. CCPR transactions will call CCPRTxnCache.OnTxnCommit/OnTxnRollback when committing/rolling back.
func (*Transaction) SetCloneTxn ¶
func (txn *Transaction) SetCloneTxn(snapshot int64)
func (*Transaction) SetHaveDDL ¶ added in v1.2.2
func (txn *Transaction) SetHaveDDL(haveDDL bool)
func (*Transaction) SetSyncProtectionJobID ¶
func (txn *Transaction) SetSyncProtectionJobID(jobID string)
SetSyncProtectionJobID sets the sync protection job ID for this transaction. This is used to pass the job ID to TN for commit-time validation.
func (*Transaction) StartStatement ¶ added in v1.0.0
func (txn *Transaction) StartStatement()
func (*Transaction) StashFlushedTombstones ¶
func (txn *Transaction) StashFlushedTombstones(stats objectio.ObjectStats)
func (*Transaction) String ¶
func (txn *Transaction) String() string
func (*Transaction) UpdateSnapshotWriteOffset ¶ added in v1.1.2
func (txn *Transaction) UpdateSnapshotWriteOffset()
func (*Transaction) WriteBatch ¶
func (txn *Transaction) WriteBatch( typ int, note string, accountId uint32, databaseId uint64, tableId uint64, databaseName string, tableName string, bat *batch.Batch, tnStore DNStore) (genRowidVec *vector.Vector, err error)
WriteBatch used to write data to the transaction buffer insert/delete/update all use this api truncate : it denotes the batch with typ DELETE on mo_tables is generated when Truncating a table.
NOTE: For Insert type, rowid is generated in this function. Be carefule use this function multiple times for the same batch
func (*Transaction) WriteFile ¶
func (txn *Transaction) WriteFile( typ int, accountId uint32, databaseId, tableId uint64, databaseName, tableName string, fileName string, bat *batch.Batch, tnStore DNStore, ) error
WriteFile used to add a s3 file information to the transaction buffer insert/delete/update all use this api
func (*Transaction) WriteFileLocked ¶ added in v1.0.0
func (*Transaction) WriteFileLockedSkipTransfer ¶
func (txn *Transaction) WriteFileLockedSkipTransfer( typ int, accountId uint32, databaseId, tableId uint64, databaseName, tableName string, fileName string, inputBat *batch.Batch, tnStore DNStore, ) (err error)
WriteFileLockedSkipTransfer is similar to WriteFileLocked but marks the entry to skip transfer processing. Used by CCPR for cross-cluster tombstones.
func (*Transaction) WriteOffset ¶ added in v1.1.1
func (txn *Transaction) WriteOffset() uint64
writeOffset returns the offset of the first write in the workspace
type TransferFlow ¶
type TransferFlow struct {
// contains filtered or unexported fields
}
func ConstructCNTombstoneObjectsTransferFlow ¶
func ConstructCNTombstoneObjectsTransferFlow( ctx context.Context, start, end types.TS, table *txnTable, txn *Transaction, mp *mpool.MPool, fs fileservice.FileService, ) (*TransferFlow, []zap.Field, error)
func ConstructTransferFlow ¶
func ConstructTransferFlow( table *txnTable, hiddenSelection objectio.HiddenColumnSelection, sourcer engine.Reader, isObjectDeletedFn func(*objectio.ObjectId) bool, newDataObjects []objectio.ObjectStats, mp *mpool.MPool, fs fileservice.FileService, opts ...TransferOption, ) *TransferFlow
func (*TransferFlow) Close ¶
func (flow *TransferFlow) Close() error
func (*TransferFlow) GetResult ¶
func (flow *TransferFlow) GetResult() ([]objectio.ObjectStats, []*batch.Batch)
type TransferOption ¶
type TransferOption func(*TransferFlow)
type TxnIndexEntry ¶
type TxnIndexEntry struct {
// contains filtered or unexported fields
}
TxnIndexEntry represents an entry in the txnIndex BTree, sorted by txnID It stores all objectNames associated with a transaction for fast lookup
func (TxnIndexEntry) Less ¶
func (e TxnIndexEntry) Less(other TxnIndexEntry) bool
Less compares two TxnIndexEntry by txnID for BTree ordering
type UT_ForceTransCheck ¶
type UT_ForceTransCheck struct{}
Source Files
¶
- ccpr_txn_cache.go
- change_handle.go
- db.go
- engine.go
- get_flush_ts.go
- local_disttae_datasource.go
- logtail.go
- logtail_consumer.go
- merge.go
- mo_table_stats.go
- object_list.go
- pk_filter_observe.go
- snapshot_materialized_datasource.go
- snapshot_scan.go
- stats.go
- table_meta_reader.go
- tools.go
- tracked_partitions.go
- transfer.go
- transfer_util.go
- txn.go
- txn_database.go
- txn_table.go
- txn_table_combined.go
- txn_table_combined_array.go
- txn_table_combined_partition.go
- txn_table_delegate.go
- txn_table_sharding_handle.go
- types.go
- util.go