Title: [Order 01][P1] Fix cross-bucket contamination in snapshot candidate query · Issue #59 · NEventStore/NEventStore.Persistence.SQL · GitHub
Open Graph Title: [Order 01][P1] Fix cross-bucket contamination in snapshot candidate query · Issue #59 · NEventStore/NEventStore.Persistence.SQL
X Title: [Order 01][P1] Fix cross-bucket contamination in snapshot candidate query · Issue #59 · NEventStore/NEventStore.Persistence.SQL
Description: Priority order Order: 01 of 09 Priority: P1 correctness and performance Problem GetStreamsRequiringSnapshots can mix data across buckets. Evidence: src/NEventStore.Persistence.Sql/SqlDialects/CommonSqlStatements.resx:182 The query joins ...
Open Graph Description: Priority order Order: 01 of 09 Priority: P1 correctness and performance Problem GetStreamsRequiringSnapshots can mix data across buckets. Evidence: src/NEventStore.Persistence.Sql/SqlDialects/Commo...
X Description: Priority order Order: 01 of 09 Priority: P1 correctness and performance Problem GetStreamsRequiringSnapshots can mix data across buckets. Evidence: src/NEventStore.Persistence.Sql/SqlDialects/Commo...
Opengraph URL: https://github.com/NEventStore/NEventStore.Persistence.SQL/issues/59
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Order 01][P1] Fix cross-bucket contamination in snapshot candidate query","articleBody":"## Priority order\n\nOrder: 01 of 09\nPriority: P1 correctness and performance\n\n## Problem\n\n`GetStreamsRequiringSnapshots` can mix data across buckets.\n\nEvidence:\n\n- `src/NEventStore.Persistence.Sql/SqlDialects/CommonSqlStatements.resx:182`\n- The query joins snapshots with `ON C.BucketId = @BucketId` but does not filter `Commits` with `WHERE C.BucketId = @BucketId`.\n- The snapshot join also omits `S.BucketId = C.BucketId`.\n\n## Impact\n\n- `GetStreamsToSnapshot(bucketId, threshold)` can return streams from other buckets.\n- Snapshots from another bucket with the same `StreamId` can change `SnapshotRevision`, hiding or creating snapshot candidates incorrectly.\n- The query groups more rows than needed on large multi-bucket stores.\n\n## Mandatory test-first workflow\n\n- Add failing sync and async acceptance tests first.\n- Tests must create the same `StreamId` in buckets `a` and `b`.\n- Tests must prove `GetStreamsToSnapshot(\"a\", ...)` does not return bucket `b` streams.\n- Tests must prove a snapshot in bucket `b` does not affect bucket `a` snapshot eligibility.\n- Do not change production SQL until the regression is covered.\n\n## Proposed action\n\n- Add `WHERE C.BucketId = @BucketId`.\n- Change the snapshot join to include `S.BucketId = C.BucketId`.\n- Keep the existing keyset paging predicate `C.StreamId \u003e @StreamId`.\n- Do not change Oracle SQL in this issue unless #58 is complete and Oracle tests are running; otherwise leave Oracle as a follow-up blocked by #58.\n\n## Acceptance criteria\n\n- New tests fail before the fix and pass after it.\n- Sync and async snapshot-candidate APIs behave consistently.\n- Provider-specific SQL remains covered by nearest provider tests.\n\nSource: `docs/Project-Analysis-Issue-Drafts.md`.","author":{"url":"https://github.com/AGiorgetti","@type":"Person","name":"AGiorgetti"},"datePublished":"2026-06-11T09:19:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/59/NEventStore.Persistence.SQL/issues/59"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:29291f13-b12d-506c-9bf7-e0fd4196ab02 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A36:6697C:309FD6:475255:6A4E0380 |
| html-safe-nonce | 93c7ed4a60da47c96626887d1796a9134362418e431e6b347203d2c9f4c73c40 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTM2OjY2OTdDOjMwOUZENjo0NzUyNTU6NkE0RTAzODAiLCJ2aXNpdG9yX2lkIjoiNDI5MTUyMzQ5ODUxNjI4NDI4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1d7a6f4381793d7ed2ede978783f689dbd5ffd5270dd0b678ad151dd5ddab009 |
| hovercard-subject-tag | issue:4639054830 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NEventStore/NEventStore.Persistence.SQL/59/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4dcea0dd95bdc235383b72085c87d60e072afa906661b634d56388a762d6faae/NEventStore/NEventStore.Persistence.SQL/issues/59 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4dcea0dd95bdc235383b72085c87d60e072afa906661b634d56388a762d6faae/NEventStore/NEventStore.Persistence.SQL/issues/59 |
| og:image:alt | Priority order Order: 01 of 09 Priority: P1 correctness and performance Problem GetStreamsRequiringSnapshots can mix data across buckets. Evidence: src/NEventStore.Persistence.Sql/SqlDialects/Commo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AGiorgetti |
| hostname | github.com |
| expected-hostname | github.com |
| None | df0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6 |
| turbo-cache-control | no-preview |
| go-import | github.com/NEventStore/NEventStore.Persistence.SQL git https://github.com/NEventStore/NEventStore.Persistence.SQL.git |
| octolytics-dimension-user_id | 4486767 |
| octolytics-dimension-user_login | NEventStore |
| octolytics-dimension-repository_id | 36130556 |
| octolytics-dimension-repository_nwo | NEventStore/NEventStore.Persistence.SQL |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36130556 |
| octolytics-dimension-repository_network_root_nwo | NEventStore/NEventStore.Persistence.SQL |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 52bde38e24398476f8eb1e0760c81346c6a00812 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width