Skip to content
Merged
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
12 changes: 12 additions & 0 deletions flow/connectors/clickhouse/qrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log/slog"

"github.com/PeerDB-io/peerdb/flow/generated/protos"
"github.com/PeerDB-io/peerdb/flow/internal"
"github.com/PeerDB-io/peerdb/flow/model"
"github.com/PeerDB-io/peerdb/flow/shared"
)
Expand Down Expand Up @@ -44,6 +45,17 @@ func (c *ClickHouseConnector) ConsolidateQRepPartitions(_ context.Context, confi
// CleanupQRepFlow function for clickhouse connector
func (c *ClickHouseConnector) CleanupQRepFlow(ctx context.Context, config *protos.QRepConfig) error {
flowName := config.FlowJobName

skipCleanup, err := internal.PeerDBClickHouseSkipStagingCleanup(ctx, config.Env)
if err != nil {
return fmt.Errorf("failed to read staging cleanup config: %w", err)
}
if skipCleanup {
c.logger.Info("Skipping staging cleanup after QRepFlow (PEERDB_CLICKHOUSE_SKIP_STAGING_CLEANUP enabled)",
slog.String("stagingPath", c.staging.BucketPath()), slog.String("flowName", flowName))
return nil
}

c.logger.Info("Cleaning up stage after QRepFlow",
slog.String("stagingPath", c.staging.BucketPath()), slog.String("flowName", flowName))

Expand Down
13 changes: 13 additions & 0 deletions flow/internal/dynamicconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ var DynamicSettings = [...]*protos.DynamicSetting{
ApplyMode: protos.DynconfApplyMode_APPLY_MODE_IMMEDIATE,
TargetForSetting: protos.DynconfTarget_CLICKHOUSE,
},
{
Name: "PEERDB_CLICKHOUSE_SKIP_STAGING_CLEANUP",
Description: "Skip deleting ClickHouse staging avro files after a QRep/snapshot flow completes. " +
"Enable to retain staging artifacts for downstream pipelines that consume them",
DefaultValue: "false",
ValueType: protos.DynconfValueType_BOOL,
ApplyMode: protos.DynconfApplyMode_APPLY_MODE_IMMEDIATE,
TargetForSetting: protos.DynconfTarget_CLICKHOUSE,
},
{
Name: "PEERDB_S3_UUID_PREFIX",
Description: "Use random UUID as prefix instead of flow name, can help partitioning on non-AWS based s3 providers",
Expand Down Expand Up @@ -758,6 +767,10 @@ func PeerDBClickHouseStagingBucketName(ctx context.Context, env map[string]strin
return dynLookup(ctx, env, "PEERDB_CLICKHOUSE_STAGING_BUCKET_NAME")
}

func PeerDBClickHouseSkipStagingCleanup(ctx context.Context, env map[string]string) (bool, error) {
return dynamicConfBool(ctx, env, "PEERDB_CLICKHOUSE_SKIP_STAGING_CLEANUP")
}

func PeerDBClickHouseAWSS3BucketName(ctx context.Context, env map[string]string) (string, error) {
return dynLookup(ctx, env, "PEERDB_CLICKHOUSE_AWS_S3_BUCKET_NAME")
}
Expand Down
Loading