Skip to content

Commit f7ba7a9

Browse files
authored
Always chunk Avro on uncompressed bytes (#4165)
It's been running for some time without any issues Closes DBI-581
1 parent 0d3beec commit f7ba7a9

5 files changed

Lines changed: 5 additions & 54 deletions

File tree

flow/connectors/clickhouse/avro_sync.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,6 @@ func (s *ClickHouseAvroSyncMethod) pushDataToS3ForSnapshot(
193193
return nil, 0, err
194194
}
195195

196-
trackUncompressed, err := internal.PeerDBS3ChunkOnUncompressed(ctx, config.Env)
197-
if err != nil {
198-
return nil, 0, err
199-
}
200-
if config.SourceType == protos.DBType_MONGO {
201-
trackUncompressed = true
202-
}
203-
204196
s.logger.Info("writing avro chunks to S3 start",
205197
slog.String("partitionId", partition.PartitionId),
206198
slog.Int64("bytesPerAvroFile", bytesPerAvroFile))
@@ -210,7 +202,7 @@ func (s *ClickHouseAvroSyncMethod) pushDataToS3ForSnapshot(
210202
substream := model.NewQRecordStream(0)
211203
substream.SetSchema(schema)
212204
substream.SetSchemaDebug(stream.SchemaDebug())
213-
sizeTracker := model.QRecordAvroChunkSizeTracker{TrackUncompressed: trackUncompressed}
205+
sizeTracker := model.QRecordAvroChunkSizeTracker{}
214206
go func() {
215207
recordsDone := true
216208
for record := range stream.Records {

flow/connectors/utils/avro_writer.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/PeerDB-io/peerdb/flow/internal"
2020
"github.com/PeerDB-io/peerdb/flow/model"
2121
"github.com/PeerDB-io/peerdb/flow/pkg/common"
22-
"github.com/PeerDB-io/peerdb/flow/shared"
2322
"github.com/PeerDB-io/peerdb/flow/shared/types"
2423
)
2524

@@ -125,13 +124,7 @@ func (p *peerDBOCFWriter) WriteRecordsToS3(
125124
}
126125
w.Close()
127126
}()
128-
var writer io.Writer
129-
if p.sizeTracker == nil || p.sizeTracker.TrackUncompressed {
130-
writer = w
131-
} else {
132-
writer = shared.NewWatchWriter(w, &p.sizeTracker.Bytes)
133-
}
134-
numRows, writeOcfError = p.WriteOCF(ctx, env, writer, typeConversions, numericTruncator)
127+
numRows, writeOcfError = p.WriteOCF(ctx, env, w, typeConversions, numericTruncator)
135128
}()
136129

137130
partSize, err := internal.PeerDBS3PartSize(ctx, env)
@@ -255,7 +248,7 @@ func (p *peerDBOCFWriter) writeRecordsToOCFWriter(
255248
return 0, err
256249
}
257250

258-
calcSize := p.sizeTracker != nil && p.sizeTracker.TrackUncompressed
251+
calcSize := p.sizeTracker != nil
259252
for qrecord := range p.stream.Records {
260253
if err := ctx.Err(); err != nil {
261254
return numRows.Load(), err

flow/internal/dynamicconf.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,12 @@ var DynamicSettings = [...]*protos.DynamicSetting{
193193
},
194194
{
195195
Name: "PEERDB_S3_BYTES_PER_AVRO_FILE",
196-
Description: "S3 upload chunk size in bytes, needed for large unpartitioned initial loads.",
196+
Description: "S3 upload chunk size in bytes before compression, needed for large unpartitioned initial loads.",
197197
DefaultValue: "1000000000",
198198
ValueType: protos.DynconfValueType_INT,
199199
ApplyMode: protos.DynconfApplyMode_APPLY_MODE_IMMEDIATE,
200200
TargetForSetting: protos.DynconfTarget_CLICKHOUSE,
201201
},
202-
{
203-
Name: "PEERDB_S3_CHUNK_ON_UNCOMPRESSED",
204-
Description: "Track uncompressed Avro size during initial load, following the in-memory size on the destination.",
205-
DefaultValue: "true",
206-
ValueType: protos.DynconfValueType_BOOL,
207-
ApplyMode: protos.DynconfApplyMode_APPLY_MODE_IMMEDIATE,
208-
TargetForSetting: protos.DynconfTarget_CLICKHOUSE,
209-
},
210202
{
211203
Name: "PEERDB_QUEUE_FORCE_TOPIC_CREATION",
212204
Description: "Force auto topic creation in mirrors, applies to Kafka and PubSub mirrors",
@@ -789,10 +781,6 @@ func PeerDBMetricsRecordAggregatesEnabled(ctx context.Context, env map[string]st
789781
return dynamicConfBool(ctx, env, "PEERDB_METRICS_RECORD_AGGREGATES_ENABLED")
790782
}
791783

792-
func PeerDBS3ChunkOnUncompressed(ctx context.Context, env map[string]string) (bool, error) {
793-
return dynamicConfBool(ctx, env, "PEERDB_S3_CHUNK_ON_UNCOMPRESSED")
794-
}
795-
796784
func PeerDBPostgresApplyCtidBlockPartitioning(ctx context.Context, env map[string]string) (bool, error) {
797785
return dynamicConfBool(ctx, env, "PEERDB_POSTGRES_APPLY_CTID_BLOCK_PARTITIONING_OVERRIDE")
798786
}

flow/model/conversion_avro.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ type QRecordAvroSchemaDefinition struct {
110110
}
111111

112112
type QRecordAvroChunkSizeTracker struct {
113-
TrackUncompressed bool
114-
Bytes atomic.Int64
113+
Bytes atomic.Int64
115114
}
116115

117116
func GetAvroSchemaDefinition(

flow/shared/watchwriter.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)