Raise bag_replicator task memory to fit its 3G heap - #1193
Merged
Conversation
The replicator runs with -Xms2G -Xmx3G but only had a 2048MB task, so large bags get OOM-killed mid-replication with nothing logged (seen with b33765170 / ingest 711eef99 dead-lettering on the Azure replicator input queue). Match the verifier's 4096MB. Also add darwin_arm64/linux hashes to the stack_prod provider lock.
The lock file pinned hashicorp/aws 5.13.0 (Aug 2023), which planned replacement of ~150 inline IAM role policies created in 2020 with an auto-generated name_prefix the config never set. Provider 5.100 treats name/name_prefix as computed and the churn disappears: a full plan now contains only intended changes. Pin ~> 5.0 at the root (nothing else constrains the provider) and pin transition_default_minimum_object_size on the working-storage lifecycle rules, where 5.100's new default (all_storage_classes_128K) would have changed transition behaviour for small objects.
This was referenced Aug 13, 2026
storage-prod: bag replicator OOM dead-lettered an Azure replication
wellcomecollection/platform#6517
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change?
The bag_replicator runs a JVM configured for a 3G heap (
-Xss6M -Xms2G -Xmx3G) inside a 2048 MB ECS task, so a large bag gets the container OOM-killed part way through replication with nothing written to the logs. That is what dead-lettered ingest711eef99-8d63-4f3f-907a-6dcdc405d26d(bagb33765170, digitised, v1, 1.5 GB across 3,333 files) on the Azure replicator input queue after three attempts, while the primary and Glacier replicas succeeded. Task memory now matches the bag_verifier sitting next to it at 4096 MB, which covers all three replicators in prod and staging.Getting that applied meant clearing something else first. stack_prod's lock file still pinned hashicorp/aws 5.13.0 from August 2023, under which any full plan proposed replacing around 150 inline IAM role policies, so applies had to be done resource by resource. Moving to 5.100.0 makes the whole stack safe to apply again.
Where the IAM churn came from and what the upgrade pulls in
The policies were created in 2020 and AWS recorded
name_prefix = "terraform-"against them, which the config never sets. 5.13.0 read that as drift and wanted to recreate each one; 5.100.0 treatsnameandname_prefixas computed, and the churn disappears.The provider is now pinned
~> 5.0at the root, since nothing else constrained it, and the lock file carries hashes for both the local and CI platforms.transition_default_minimum_object_sizeis pinned tovaries_by_storage_classon the two working-storage lifecycle rules, because 5.100's new default ofall_storage_classes_128Kwould otherwise silently stop objects under 128K transitioning.How to test
With terraform 1.6.5 and provider 5.100.0, a full
terraform planinstack_prodshould contain only the intended changes: three task definition replacements, three service updates, and two cosmetic lifecycle normalisations. This has already been applied to prod, so a plan there should now be clean. The behavioural check is re-ingesting a bag of comparable size and watching the Azure replicator complete rather than time out and retry.How can we measure success?
storage-prod_bag_replicator_azure_input_dlq_not_emptystays quiet, and replicator MemoryUtilization stops spiking to the high 80s and taking the task with it. The failed ingest above can be retried.Have we considered potential risks?
The memory increase triggers a rolling replacement of three services per stack; in-flight messages go back to the queue and are picked up again, and the replicators are idempotent, so the window is not interesting. The provider upgrade is the larger risk, which is why the full plan was read before applying rather than trusting a targeted one.
stack_staging keeps its own lock file at the old provider version. It will want the same
terraform init -upgradewhen it is next touched, and anyone applying staging before that will still see the IAM policy churn.