Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable oneSync always #1755

Merged
merged 3 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 0 additions & 5 deletions flow/peerdbenv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ func PeerDBCDCDiskSpillMemPercentThreshold() int {
return getEnvInt("PEERDB_CDC_DISK_SPILL_MEM_PERCENT_THRESHOLD", -1)
}

// PEERDB_DISABLE_ONE_SYNC
func PeerDBDisableOneSync() bool {
return getEnvBool("PEERDB_DISABLE_ONE_SYNC", false)
}

// GOMEMLIMIT is a variable internal to Golang itself, we use this for internal targets, 0 means no maximum
func PeerDBFlowWorkerMaxMemBytes() uint64 {
return getEnvUint[uint64]("GOMEMLIMIT", 0)
Expand Down
52 changes: 22 additions & 30 deletions flow/workflows/sync_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,30 @@ func SyncFlowWorkflow(
parent := workflow.GetInfo(ctx).ParentWorkflowExecution
logger := log.With(workflow.GetLogger(ctx), slog.String(string(shared.FlowNameKey), config.FlowJobName))

enableOneSync := GetSideEffect(ctx, func(_ workflow.Context) bool {
return !peerdbenv.PeerDBDisableOneSync()
})
var fMaintain workflow.Future
var sessionID string
syncSessionCtx := ctx
if enableOneSync {
sessionOptions := &workflow.SessionOptions{
CreationTimeout: 5 * time.Minute,
ExecutionTimeout: 144 * time.Hour,
HeartbeatTimeout: time.Minute,
}
var err error
syncSessionCtx, err = workflow.CreateSession(ctx, sessionOptions)
if err != nil {
return err
}
defer workflow.CompleteSession(syncSessionCtx)
sessionID = workflow.GetSessionInfo(syncSessionCtx).SessionID
sessionOptions := &workflow.SessionOptions{
CreationTimeout: 5 * time.Minute,
ExecutionTimeout: 14 * 24 * time.Hour,
HeartbeatTimeout: time.Minute,
}

maintainCtx := workflow.WithActivityOptions(syncSessionCtx, workflow.ActivityOptions{
StartToCloseTimeout: 14 * 24 * time.Hour,
HeartbeatTimeout: time.Minute,
WaitForCancellation: true,
})
fMaintain = workflow.ExecuteActivity(
maintainCtx,
flowable.MaintainPull,
config,
sessionID,
)
syncSessionCtx, err := workflow.CreateSession(ctx, sessionOptions)
if err != nil {
return err
}
defer workflow.CompleteSession(syncSessionCtx)

sessionID := workflow.GetSessionInfo(syncSessionCtx).SessionID
maintainCtx := workflow.WithActivityOptions(syncSessionCtx, workflow.ActivityOptions{
StartToCloseTimeout: 14 * 24 * time.Hour,
HeartbeatTimeout: time.Minute,
WaitForCancellation: true,
})
fMaintain := workflow.ExecuteActivity(
maintainCtx,
flowable.MaintainPull,
config,
sessionID,
)

var stop, syncErr bool
currentSyncFlowNum := 0
Expand Down
Loading