Skip to content

fix(ops): write plan_status snapshots only when they change - #110

Merged
glrs merged 1 commit into
NationalGenomicsInfrastructure:devfrom
glrs:fix/ops-skip-unchanged-snapshots
Oct 16, 2026
Merged

glrs merged 1 commit into
NationalGenomicsInfrastructure:devfrom
glrs:fix/ops-skip-unchanged-snapshots

Conversation

@glrs

@glrs glrs commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

This PR improves the operations consumer by ensuring only changed snapshots are written, reducing unnecessary writes and traffic to the DB. It also updates documentation and adds comprehensive tests to verify the new behavior.

Efficiency improvements to snapshot writing:

  • The FileSpoolConsumer now writes a plan's snapshot only if its content (excluding updated_at) has changed since the last write by that consumer, or if the consumer has not written it before. This prevents redundant writes when no new events have occurred. [1] [2] [3]
  • A new internal method _content_fingerprint computes a SHA-256 digest of a snapshot's content (excluding updated_at) to efficiently detect changes.

Documentation updates:

  • The operational snapshots section in plan_execution.md is updated to clarify that only changed snapshots are written, and to describe the behavior when snapshots are deleted or when a consumer restarts.
  • The docstring for OpsConsumerService is revised to reflect the new behavior of writing only changed snapshots.
  • The docstring for FileSpoolConsumer is updated to describe the new snapshot writing logic.

Testing enhancements:

  • A new test class, TestConsumerSkipsUnchangedSnapshots, is added to verify that unchanged snapshots are not rewritten, that new events trigger writes, that failed writes are retried, and that consumers write all snapshots on startup. CouchDB revision behavior is also tested.
  • Supporting imports and setup code for these tests are included. [1] [2]

(References: [1] [2] [3] [4] [5] [6] [7] [8] [9]

@glrs
glrs merged commit 418c96d into NationalGenomicsInfrastructure:dev Oct 16, 2026
5 checks passed
@glrs
glrs deleted the fix/ops-skip-unchanged-snapshots branch October 16, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant