fix(cloudstore): invalidate dashboard cache after every InsertMutationBatch commit#354
Open
danielgap wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes dashboard staleness in the cloudstore write path by ensuring InsertMutationBatch invalidates the dashboard read-model cache after every successful commit (including batches that produce no materialized chunks, e.g., relation-only batches), and adds a regression test to prevent reintroducing the bug.
Changes:
- Make
InsertMutationBatchalways callinvalidateDashboardReadModel()after a successful transaction commit. - Add a regression test proving cache invalidation happens even when the mutation batch yields zero materialized chunks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
internal/cloud/cloudstore/cloudstore.go |
Unconditionally invalidate the dashboard read-model cache after committing InsertMutationBatch. |
internal/cloud/cloudstore/cloudstore_test.go |
Add regression coverage for cache invalidation on a relation-only mutation batch (zero chunks). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| db, err := sql.Open("cloudstore-partial-fail-driver", "dsn") | ||
| if err != nil { | ||
| t.Fatalf("open: %v", err) | ||
| } |
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.
🔗 Linked Issue
Closes #251
🏷️ PR Type
type:bug— Bug fix📝 Summary
InsertMutationBatchnow unconditionally invalidates the dashboard read model cache after every successful commit, aligning its behavior withWriteChunk.relation) left the cache stale, causing 404s on the dashboard until a manual restart.📂 Changes
internal/cloud/cloudstore/cloudstore.goinvalidateDashboardReadModel()outside theif len(chunks) > 0conditional so it always runs after commitinternal/cloud/cloudstore/cloudstore_test.goTestInsertMutationBatchInvalidatesDashboardReadModelregression test using a relation-only batch (zero chunks)🧪 Test Plan
go test ./internal/cloud/cloudstore/— all pass (47 tests, 0 failures)go test -tags e2e ./internal/server/...— skipped (no local Postgres)InsertMutationBatchwith a relation-only batch triggers cache invalidation🤖 Automated Checks
These run automatically and all must pass before merge:
Closes #N/Fixes #N/Resolves #Nstatus:approvedlabeltype:*labelgo test ./...passesgo test -tags e2e ./internal/server/...passes✅ Contributor Checklist
Closes #251)type:*label to this PR (type:bug)go test ./internal/cloud/cloudstore/Co-Authored-Bytrailers in commits💬 Notes for Reviewers
The root cause is that
InsertMutationBatchguarded the cache invalidation behindif len(chunks) > 0, butWriteChunk(the other write path) invalidates unconditionally. This meant that mutations arriving via autosync that contained only non-materializable entities (likerelation) never invalidated the cache, making the dashboard stale until a server restart. The fix is a one-line change that matches the proven pattern fromWriteChunk.