-
Notifications
You must be signed in to change notification settings - Fork 142
Db ivm groupBy bug #1035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Db ivm groupBy bug #1035
Conversation
Add tests to verify that the groupBy operator correctly emits paired delete+insert messages when aggregates change. These tests investigate a reported bug where the D2 pipeline might emit an insert without a corresponding delete in certain edge cases. The tests verify: - Incremental updates emit paired delete+insert for aggregate changes - Rapid incremental updates maintain correct message pairing - Multiple groups with interleaved updates emit correct pairs - Message accumulation correctly pairs deletes and inserts All tests pass at the db-ivm level, suggesting the issue may be at the db package layer or involves specific timing conditions.
Add tests at the db package level to investigate the reported bug where groupBy might emit inserts without corresponding deletes. These tests complement the db-ivm level tests and verify: - Basic incremental updates with same groupBy key - Multiple incremental updates to same group - Incremental updates with sum aggregate - Multiple groups with incremental updates - Batch then incremental updates All tests pass, indicating the standard scenarios work correctly. The bug may only manifest in specific async or timing conditions.
|
Cursor Agent can help with this pull request. Just |
|
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 88.5 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.35 kB ℹ️ View Unchanged
|
Extended the test file to cover all scenarios from PR 1030: - D2 output tracing to verify paired delete+insert emissions - Direct bug reproduction tests for sync layer behavior - Subquery pattern (groupBy as source for orderBy/limit) - Rapid sequential inserts - Multiple events in single batch Investigation findings: - All tests pass without the PR's defensive fix - D2 correctly emits paired delete+insert for aggregate updates - The accumulator correctly consolidates them into update operations - The bug may only manifest in specific async/timing edge cases not covered by synchronous tests These tests serve as regression tests for groupBy incremental updates.
🎯 Changes
Added comprehensive tests to
packages/db-ivm/tests/operators/groupBy.test.tsandpackages/db/tests/query/group-by-incremental-test.test.tsto verify the correct behavior ofgroupByincremental updates.This investigation aimed to reproduce a reported bug where
groupByemitted duplicate inserts without corresponding deletes, but the bug could not be reproduced in synchronous test scenarios at either thedb-ivmordblevel. The new tests confirm that thegroupByoperator correctly emits paired delete and insert messages when aggregate values change.✅ Checklist
pnpm test:pr.🚀 Release Impact