Skip to content

Commit

Permalink
disable redo event cache by default
Browse files Browse the repository at this point in the history
Signed-off-by: qupeng <[email protected]>
  • Loading branch information
hicqu committed Nov 23, 2023
1 parent 78e870c commit ba2daee
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
16 changes: 7 additions & 9 deletions cdc/processor/sinkmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,13 @@ func New(
m.redoTaskChan = make(chan *redoTask)
m.redoWorkerAvailable = make(chan struct{}, 1)

if changefeedInfo.Config.Consistent.EnableEventCache {
// Use 3/4 memory quota as redo quota, and 1/2 again for redo cache.
m.sinkMemQuota = memquota.NewMemQuota(changefeedID, changefeedInfo.Config.MemoryQuota/4*1, "sink")
redoQuota := changefeedInfo.Config.MemoryQuota / 4 * 3
m.redoMemQuota = memquota.NewMemQuota(changefeedID, redoQuota, "redo")
m.eventCache = newRedoEventCache(changefeedID, redoQuota/2*1)
} else {
m.sinkMemQuota = memquota.NewMemQuota(changefeedID, changefeedInfo.Config.MemoryQuota/2, "sink")
m.redoMemQuota = memquota.NewMemQuota(changefeedID, changefeedInfo.Config.MemoryQuota/2, "redo")
redoQuota := uint64(float64(changefeedInfo.Config.MemoryQuota*changefeedInfo.Config.Consistent.MemoryQuotaPercentage) / 100)
sinkQuota := changefeedInfo.Config.MemoryQuota - redoQuota
m.sinkMemQuota = memquota.NewMemQuota(changefeedID, sinkQuota, "sink")
m.redoMemQuota = memquota.NewMemQuota(changefeedID, redoQuota, "redo")
eventCache := uint64(float64(redoQuota*changefeedInfo.Config.Consistent.EventCachePercentage) / 100)
if eventCache > 0 {
m.eventCache = newRedoEventCache(changefeedID, eventCache)
}
} else {
m.sinkMemQuota = memquota.NewMemQuota(changefeedID, changefeedInfo.Config.MemoryQuota, "sink")
Expand Down
9 changes: 6 additions & 3 deletions pkg/config/config_test_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const (
"flush-worker-num": 8,
"storage": "",
"use-file-backend": false,
"enable-event-cache": false
"memory-quota-percentage": 50,
"event-cache-percentage": 0
},
"scheduler": {
"enable-table-across-nodes": false,
Expand Down Expand Up @@ -315,7 +316,8 @@ const (
"flush-worker-num": 8,
"storage": "",
"use-file-backend": false,
"enable-event-cache": false
"memory-quota-percentage": 50,
"event-cache-percentage": 0
},
"scheduler": {
"enable-table-across-nodes": true,
Expand Down Expand Up @@ -468,7 +470,8 @@ const (
"flush-worker-num": 8,
"storage": "",
"use-file-backend": false,
"enable-event-cache": false
"memory-quota-percentage": 50,
"event-cache-percentage": 0
},
"scheduler": {
"enable-table-across-nodes": true,
Expand Down
6 changes: 5 additions & 1 deletion pkg/config/consistent.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ type ConsistentConfig struct {
FlushWorkerNum int `toml:"flush-worker-num" json:"flush-worker-num"`
Storage string `toml:"storage" json:"storage"`
UseFileBackend bool `toml:"use-file-backend" json:"use-file-backend"`
EnableEventCache bool `toml:"enable-event-cache" json:"enable-event-cache"`
// ReplicaConfig.MemoryQuota * MemoryQuotaPercentage / 100 will be used for redo events.
MemoryQuotaPercentage uint64 `toml:"memory-quota-percentage" json:"memory-quota-percentage"`
// ReplicaConfig.MemoryQuota * MemoryQuotaPercentage / 100 * EventCachePercentage / 100
// will be used for redo cache.
EventCachePercentage uint64 `toml:"event-cache-percentage" json:"event-cache-percentage"`
}

// ValidateAndAdjust validates the consistency config and adjusts it if necessary.
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/replica_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ var defaultReplicaConfig = &ReplicaConfig{
FlushWorkerNum: redo.DefaultFlushWorkerNum,
Storage: "",
UseFileBackend: false,
MemoryQuotaPercentage: 50,
EventCachePercentage: 0,
},
Scheduler: &ChangefeedSchedulerConfig{
EnableTableAcrossNodes: false,
Expand Down

0 comments on commit ba2daee

Please sign in to comment.