Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions downstreamadapter/dispatchermanager/dispatcher_manager_redo.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,17 @@ func initRedoComponet(
}
var err error
redoDispatcherMap := newDispatcherMap[*dispatcher.RedoDispatcher]()
redoSink, err := redo.New(ctx, changefeedID, manager.config.Consistent)
if err != nil {
return err
}
redoSchemaIDToDispatchers := dispatcher.NewSchemaIDToDispatchers()

totalQuota := manager.sinkQuota
consistentMemoryUsage := manager.config.Consistent.MemoryUsage
if consistentMemoryUsage == nil {
consistentMemoryUsage = config.GetDefaultReplicaConfig().Consistent.MemoryUsage
}
redoQuota := totalQuota * consistentMemoryUsage.MemoryQuotaPercentage / 100
redoSink, err := redo.New(ctx, changefeedID, manager.config.Consistent, redoQuota)
if err != nil {
return err
}
redoSchemaIDToDispatchers := dispatcher.NewSchemaIDToDispatchers()

manager.writePathMu.Lock()
if manager.writePathClosed.Load() {
Expand Down
2 changes: 1 addition & 1 deletion downstreamadapter/sink/cloudstorage/buffer_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
"context"
"time"

"github.com/pingcap/ticdc/downstreamadapter/sink/cloudstorage/spool"
"github.com/pingcap/ticdc/downstreamadapter/sink/metrics"
"github.com/pingcap/ticdc/pkg/cloudstorage"
"github.com/pingcap/ticdc/pkg/common"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/sink/spool"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion downstreamadapter/sink/cloudstorage/buffer_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"testing"
"time"

"github.com/pingcap/ticdc/downstreamadapter/sink/cloudstorage/spool"
"github.com/pingcap/ticdc/pkg/cloudstorage"
commonType "github.com/pingcap/ticdc/pkg/common"
commonEvent "github.com/pingcap/ticdc/pkg/common/event"
"github.com/pingcap/ticdc/pkg/errors"
"github.com/pingcap/ticdc/pkg/sink/codec/common"
"github.com/pingcap/ticdc/pkg/sink/spool"
"github.com/stretchr/testify/require"
)

Expand Down
3 changes: 2 additions & 1 deletion downstreamadapter/sink/cloudstorage/dml_writers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import (
"context"
"time"

"github.com/pingcap/ticdc/downstreamadapter/sink/cloudstorage/spool"
"github.com/pingcap/ticdc/downstreamadapter/sink/columnselector"
sinkmetrics "github.com/pingcap/ticdc/downstreamadapter/sink/metrics"
"github.com/pingcap/ticdc/pkg/cloudstorage"
commonType "github.com/pingcap/ticdc/pkg/common"
commonEvent "github.com/pingcap/ticdc/pkg/common/event"
"github.com/pingcap/ticdc/pkg/metrics"
"github.com/pingcap/ticdc/pkg/sink/codec/common"
"github.com/pingcap/ticdc/pkg/sink/spool"
"github.com/pingcap/ticdc/utils/chann"
"github.com/pingcap/tidb/pkg/objstore/storeapi"
"go.uber.org/atomic"
Expand Down Expand Up @@ -68,6 +68,7 @@ func newDMLWriters(
changefeedID,
spool.WithRootDir(config.SpoolBaseDir),
spool.WithDiskQuotaBytes(config.SpoolDiskQuota),
spool.WithMetrics(newSpoolMetrics(changefeedID)),
)
if err != nil {
return nil, err
Expand Down
100 changes: 0 additions & 100 deletions downstreamadapter/sink/cloudstorage/spool/budget.go

This file was deleted.

81 changes: 0 additions & 81 deletions downstreamadapter/sink/cloudstorage/spool/budget_test.go

This file was deleted.

45 changes: 45 additions & 0 deletions downstreamadapter/sink/cloudstorage/spool_metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2026 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package cloudstorage

import (
sinkmetrics "github.com/pingcap/ticdc/downstreamadapter/sink/metrics"
"github.com/pingcap/ticdc/pkg/common"
"github.com/pingcap/ticdc/pkg/sink/spool"
)

func newSpoolMetrics(changefeedID common.ChangeFeedID) *spool.Metrics {
keyspace := changefeedID.Keyspace()
changefeed := changefeedID.Name()
return &spool.Metrics{
MemoryBytes: sinkmetrics.CloudStorageSpoolMemoryBytesGauge.WithLabelValues(keyspace, changefeed),
DiskBytes: sinkmetrics.CloudStorageSpoolDiskBytesGauge.WithLabelValues(keyspace, changefeed),
PendingPostEnqueue: sinkmetrics.CloudStoragePendingPostEnqueueGauge.WithLabelValues(keyspace, changefeed),
DiskQuotaWaiters: sinkmetrics.CloudStorageSpoolDiskQuotaWaitersGauge.WithLabelValues(keyspace, changefeed),
DiskQuotaWait: sinkmetrics.CloudStorageSpoolDiskQuotaWaitDurationHistogram.WithLabelValues(keyspace, changefeed),
LoadedBytes: sinkmetrics.CloudStorageLoadBytesHistogram.WithLabelValues(keyspace, changefeed),
RotatedCount: sinkmetrics.CloudStorageRotateCountCounter.WithLabelValues(keyspace, changefeed),
SegmentCount: sinkmetrics.CloudStorageSpoolSegmentCountGauge.WithLabelValues(keyspace, changefeed),
Close: func() {
sinkmetrics.CloudStorageSpoolMemoryBytesGauge.DeleteLabelValues(keyspace, changefeed)
sinkmetrics.CloudStorageSpoolDiskBytesGauge.DeleteLabelValues(keyspace, changefeed)
sinkmetrics.CloudStoragePendingPostEnqueueGauge.DeleteLabelValues(keyspace, changefeed)
sinkmetrics.CloudStorageSpoolDiskQuotaWaitersGauge.DeleteLabelValues(keyspace, changefeed)
sinkmetrics.CloudStorageSpoolDiskQuotaWaitDurationHistogram.DeleteLabelValues(keyspace, changefeed)
sinkmetrics.CloudStorageLoadBytesHistogram.DeleteLabelValues(keyspace, changefeed)
sinkmetrics.CloudStorageRotateCountCounter.DeleteLabelValues(keyspace, changefeed)
sinkmetrics.CloudStorageSpoolSegmentCountGauge.DeleteLabelValues(keyspace, changefeed)
},
}
}
2 changes: 1 addition & 1 deletion downstreamadapter/sink/cloudstorage/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (
"time"

"github.com/pingcap/log"
"github.com/pingcap/ticdc/downstreamadapter/sink/cloudstorage/spool"
"github.com/pingcap/ticdc/downstreamadapter/sink/metrics"
"github.com/pingcap/ticdc/pkg/cloudstorage"
"github.com/pingcap/ticdc/pkg/common"
"github.com/pingcap/ticdc/pkg/errors"
pmetrics "github.com/pingcap/ticdc/pkg/metrics"
"github.com/pingcap/ticdc/pkg/sink/spool"
"github.com/pingcap/tidb/pkg/objstore/storeapi"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion downstreamadapter/sink/cloudstorage/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import (
"testing"
"time"

"github.com/pingcap/ticdc/downstreamadapter/sink/cloudstorage/spool"
"github.com/pingcap/ticdc/pkg/cloudstorage"
commonType "github.com/pingcap/ticdc/pkg/common"
commonEvent "github.com/pingcap/ticdc/pkg/common/event"
"github.com/pingcap/ticdc/pkg/config"
"github.com/pingcap/ticdc/pkg/metrics"
"github.com/pingcap/ticdc/pkg/pdutil"
"github.com/pingcap/ticdc/pkg/sink/codec/common"
"github.com/pingcap/ticdc/pkg/sink/spool"
"github.com/pingcap/ticdc/pkg/util"
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/objstore/objectio"
Expand Down
8 changes: 7 additions & 1 deletion downstreamadapter/sink/helper/row_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ import (
// NewPostFlushRowCallback returns a row-level callback that triggers txn-level
// PostFlush exactly once when the callback has been invoked totalCount times.
func NewPostFlushRowCallback(event *event.DMLEvent, totalCount uint64) func() {
return NewRowCallback(totalCount, event.PostFlush)
}

// NewRowCallback returns a row-level callback that triggers callback exactly
// once after it has been invoked totalCount times.
func NewRowCallback(totalCount uint64, callback func()) func() {
var calledCount atomic.Uint64
return func() {
if calledCount.Inc() == totalCount {
event.PostFlush()
callback()
}
}
}
Loading
Loading