Skip to content

Commit

Permalink
Fix xmin rep when initial copy only true
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 5, 2023
1 parent 6b33eaf commit 49ed22c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion flow/e2e/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"go.temporal.io/sdk/testsuite"
)

// readFileToBytes reads a file to a byte array.
// ReadFileToBytes reads a file to a byte array.
func ReadFileToBytes(path string) ([]byte, error) {
var ret []byte

Expand Down
22 changes: 7 additions & 15 deletions flow/workflows/xmin_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (q *XminFlowExecution) consolidatePartitions(ctx workflow.Context) error {
return fmt.Errorf("failed to cleanup qrep flow: %w", err)
}

q.logger.Info("qrep flow cleaned up")
q.logger.Info("xmin flow cleaned up")

return nil
}
Expand All @@ -186,14 +186,6 @@ func XminFlowWorkflow(
config *protos.QRepConfig,
state *protos.QRepFlowState,
) error {
// register a query to get the number of partitions processed
err := workflow.SetQueryHandler(ctx, "num-partitions-processed", func() (uint64, error) {
return state.NumPartitionsProcessed, nil
})
if err != nil {
return fmt.Errorf("failed to register query handler: %w", err)
}

// get xmin run uuid via side-effect
runUUIDSideEffect := workflow.SideEffect(ctx, func(ctx workflow.Context) interface{} {
return uuid.New().String()
Expand All @@ -206,7 +198,7 @@ func XminFlowWorkflow(

q := NewXminFlowExecution(ctx, config, runUUID)

err = q.SetupWatermarkTableOnDestination(ctx)
err := q.SetupWatermarkTableOnDestination(ctx)
if err != nil {
return fmt.Errorf("failed to setup watermark table: %w", err)
}
Expand Down Expand Up @@ -238,9 +230,8 @@ func XminFlowWorkflow(
return fmt.Errorf("xmin replication failed: %w", err)
}

state.LastPartition = &protos.QRepPartition{
PartitionId: q.runUUID,
Range: &protos.PartitionRange{Range: &protos.PartitionRange_IntRange{IntRange: &protos.IntPartitionRange{Start: lastPartition}}},
if err = q.consolidatePartitions(ctx); err != nil {
return err
}

if config.InitialCopyOnly {
Expand All @@ -253,8 +244,9 @@ func XminFlowWorkflow(
return err
}

if err = q.consolidatePartitions(ctx); err != nil {
return err
state.LastPartition = &protos.QRepPartition{
PartitionId: q.runUUID,
Range: &protos.PartitionRange{Range: &protos.PartitionRange_IntRange{IntRange: &protos.IntPartitionRange{Start: lastPartition}}},
}

workflow.GetLogger(ctx).Info("Continuing as new workflow",
Expand Down

0 comments on commit 49ed22c

Please sign in to comment.