mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
The backup streamed its JSON through gzip and the cipher, but kept the stored copy as one string and handed that to Postgres in one parameter. On a seeded account of 1.25 million measurements the copy is 64 MB of base64, and the pieces, the joined string and the driver's copies of it grew the process from 309 MB to 946 MB resident. A bare process needed a heap limit above 400 MB to finish it (the new path finishes under 220 MB). With the dense retention running beside it in a 1 GB container the process died of heap exhaustion, and the backup job sat "active" until its two-hour limit marked it "job timed out" (#1031). `packBackupBlobInto` hands the stored copy on in pieces of up to 4 MB as it is produced, and `storeBackupBlob` writes them into a temporary table on its own transaction and assembles the row with one `string_agg`. The process never holds the whole copy. The account's previous copy stays in place until the new one is complete: a failure rolls back to it. Measured on the seeded account in a 1 GB container, web and worker in one process: the backup completes in about 30 s with the dense retention running beside it, where v1.39.0 crashed within 30 s. The streamed JSON also reports its progress to the job every 50 000 rows.