Skip to content

fix: add missing created_at index on wisp_events#2877

Merged
maphew merged 1 commit into
gastownhall:mainfrom
maphew:fix/2760-event-poll-inf-cast
Mar 30, 2026
Merged

fix: add missing created_at index on wisp_events#2877
maphew merged 1 commit into
gastownhall:mainfrom
maphew:fix/2760-event-poll-inf-cast

Conversation

@maphew

@maphew maphew commented Mar 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds migration 014 to create idx_wisp_events_created_at index on existing wisp_events tables
  • Updates the base schema in migration 005 so new databases include the index from the start
  • The events table already has idx_events_created_at but wisp_events was missing it, causing full table scans on WHERE created_at > ? in GetAllEventsSince

The core type mismatch bug (WHERE id > ? with int64 on CHAR(36)) was already resolved by the UUID primary keys migration (PR #2597), which changed GetAllEventsSince to use WHERE created_at > ? with time.Time. This PR adds the missing index to ensure the query uses an efficient execution path and avoids the optimizer code path that triggered the +Inf cast error.

Fixes #2760

Test plan

  • Verify migration 014 is idempotent (safe to run multiple times)
  • Verify GetAllEventsSince returns events from both tables after migration
  • Verify new database creation includes idx_wisp_events_created_at

@codecov-commenter

codecov-commenter commented Mar 29, 2026

Copy link
Copy Markdown

❌ 6 Tests Failed:

Tests completed Failed Passed Skipped
5691 6 5685 575
View the top 3 failed test(s) by shortest run time
github.com/steveyegge/beads/cmd/bd::TestCheckBeadGate_InvalidFormat
Stack Traces | 0s run time
=== RUN   TestCheckBeadGate_InvalidFormat
--- FAIL: TestCheckBeadGate_InvalidFormat (0.00s)
github.com/steveyegge/beads/cmd/bd::TestCheckBeadGate_InvalidFormat/empty
Stack Traces | 0s run time
=== RUN   TestCheckBeadGate_InvalidFormat/empty
    gate_test.go:104: reason "cross-rig bead gate \"\" cannot be checked (multi-rig routing removed)" does not contain "invalid await_id format"
--- FAIL: TestCheckBeadGate_InvalidFormat/empty (0.00s)
github.com/steveyegge/beads/cmd/bd::TestCheckBeadGate_InvalidFormat/missing_bead
Stack Traces | 0s run time
=== RUN   TestCheckBeadGate_InvalidFormat/missing_bead
    gate_test.go:104: reason "cross-rig bead gate \"my-project:\" cannot be checked (multi-rig routing removed)" does not contain "await_id missing rig name or bead ID"
--- FAIL: TestCheckBeadGate_InvalidFormat/missing_bead (0.00s)
github.com/steveyegge/beads/cmd/bd::TestCheckBeadGate_InvalidFormat/missing_rig
Stack Traces | 0s run time
=== RUN   TestCheckBeadGate_InvalidFormat/missing_rig
    gate_test.go:104: reason "cross-rig bead gate \":gt-abc\" cannot be checked (multi-rig routing removed)" does not contain "await_id missing rig name"
--- FAIL: TestCheckBeadGate_InvalidFormat/missing_rig (0.00s)
github.com/steveyegge/beads/cmd/bd::TestCheckBeadGate_InvalidFormat/no_colon
Stack Traces | 0s run time
=== RUN   TestCheckBeadGate_InvalidFormat/no_colon
    gate_test.go:104: reason "cross-rig bead gate \"my-project-mp-abc\" cannot be checked (multi-rig routing removed)" does not contain "invalid await_id format"
--- FAIL: TestCheckBeadGate_InvalidFormat/no_colon (0.00s)
github.com/steveyegge/beads/cmd/bd::TestCheckBeadGate_RigNotFound
Stack Traces | 0s run time
=== RUN   TestCheckBeadGate_RigNotFound
    gate_test.go:135: reason should mention not found: "cross-rig bead gate \"nonexistent:some-id\" cannot be checked (multi-rig routing removed)"
--- FAIL: TestCheckBeadGate_RigNotFound (0.00s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@maphew maphew force-pushed the fix/2760-event-poll-inf-cast branch 3 times, most recently from 628d4af to 5316337 Compare March 30, 2026 14:13
The wisp_events table was created without an index on created_at,
unlike the events table which has idx_events_created_at. This causes
GetAllEventsSince's UNION ALL query to perform a full table scan on
wisp_events for the WHERE created_at > ? predicate.

Without this index, Dolt's optimizer may choose a code path that
implicitly casts CHAR(36) UUID values to float64 for comparison,
causing overflow on UUIDs resembling scientific notation (e.g.
001e914b... parses as 1e914 = 10^914 → +Inf → MySQL Error 1366).

Migration 014 adds the index to existing databases. The base schema
in migration 005 is also updated so new databases get it from the
start.

Fixes gastownhall#2760
🤖 Generated with [Nori](https://nori.ai)

Co-authored-by: Nori <contact@tilework.tech>
Amp-Thread-ID: https://ampcode.com/threads/T-019d3f66-ab13-74d8-bcc7-e53e8e736eef
Co-authored-by: Amp <amp@ampcode.com>
@maphew maphew force-pushed the fix/2760-event-poll-inf-cast branch from 5316337 to df331f1 Compare March 30, 2026 15:44
@maphew maphew merged commit 8725226 into gastownhall:main Mar 30, 2026
31 checks passed
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.

GetAllEventsSince: WHERE id > ? with int64 binding on char(36) column causes Dolt +Inf cast error

2 participants