Skip to content

Commit ec0e676

Browse files
committed
fix: stamp meta:fill on deps export reuse (CM-1296)
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent f41eb3a commit ec0e676

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

services/apps/packages_worker/src/deps-dev/activities/bqExportToGcs.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
findExportedJobByGcsPrefix,
77
findLatestExportedJobByKind,
88
markJobStatus,
9+
mergeJobTableRowCounts,
910
} from '@crowd/data-access-layer'
1011
import { getServiceChildLogger } from '@crowd/logging'
1112

@@ -86,6 +87,10 @@ export async function bqExportToGcs(input: BqExportToGcsInput): Promise<BqExport
8687
{ jobKind, exportName, jobId: prior.id, gcsPrefix: prior.gcsPrefix },
8788
'exportName match — skipping BQ, loading from named export',
8889
)
90+
// A --fill-constraints run reusing an existing export must still stamp meta:fill on the
91+
// reused row, else a later --resume-job reads fill=false and reverts the merge to
92+
// ON CONFLICT DO NOTHING — silently skipping the version_constraint backfill.
93+
if (isFill) await mergeJobTableRowCounts(qx, prior.id, { 'meta:fill': 1 })
8994
return {
9095
gcsPrefix: prior.gcsPrefix,
9196
rowCount: prior.rowCountBq,
@@ -143,6 +148,9 @@ export async function bqExportToGcs(input: BqExportToGcsInput): Promise<BqExport
143148
{ jobKind, jobId: prior.id, gcsPrefix: prior.gcsPrefix },
144149
'reuseExports=true — skipping BQ, loading from prior export',
145150
)
151+
// See named-export path above: persist meta:fill so a later --resume-job keeps the
152+
// fill-constraints merge instead of reverting to ON CONFLICT DO NOTHING.
153+
if (isFill) await mergeJobTableRowCounts(qx, prior.id, { 'meta:fill': 1 })
146154
return {
147155
gcsPrefix: prior.gcsPrefix,
148156
rowCount: prior.rowCountBq,
@@ -171,6 +179,9 @@ export async function bqExportToGcs(input: BqExportToGcsInput): Promise<BqExport
171179
{ jobKind, jobId: existing.id, gcsPrefix },
172180
'GCS files already exist — reusing export',
173181
)
182+
// Same-runId reuse (Temporal retry): the export row already has meta:fill from its own
183+
// 'exporting' write, but re-stamp defensively so the fill flag can never be lost on reuse.
184+
if (isFill) await mergeJobTableRowCounts(qx, existing.id, { 'meta:fill': 1 })
174185
return { gcsPrefix, rowCount: existing.rowCountBq, bqBytesBilled: 0, jobId: existing.id }
175186
}
176187
}

0 commit comments

Comments
 (0)