Skip to content

Complete DBUpdates support for x/sqlite driver#1158

Merged
flimzy merged 21 commits intomainfrom
sqlite44
Feb 18, 2026
Merged

Complete DBUpdates support for x/sqlite driver#1158
flimzy merged 21 commits intomainfrom
sqlite44

Conversation

@flimzy
Copy link
Member

@flimzy flimzy commented Feb 18, 2026

No description provided.

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.42%. Comparing base (8fe5c61) to head (84614d3).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1158   +/-   ##
=======================================
  Coverage   61.42%   61.42%           
=======================================
  Files         293      293           
  Lines       19314    19314           
=======================================
+ Hits        11863    11864    +1     
  Misses       6895     6895           
+ Partials      556      555    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Adds polling-based longpoll and continuous feed modes to the SQLite driver's
DBUpdates implementation. Uses exponential backoff (100ms-10s) to efficiently
poll for new database creation/deletion events. Batches updates by keeping the
SQL cursor open rather than re-querying for each update. Also fixes normal feed
mode to properly handle since="now" parameter.
- Since() now returns the suffix portion of compound sequence IDs
  (e.g. "42-foo" yields seq=42, suffix="foo") rather than the full string
- sqlite drivers discard the suffix (unused) and drop pointer indirection
  on since, since since=0 and unspecified are semantically equivalent
Removes redundant since, sinceNow, feed, and lastSeq parameters from
the signature; the function now derives all it needs directly from opts.
…Membership)

ClusterSetup("enable_single_node") creates _users, _replicator, and _global_changes
idempotently, matching CouchDB's setup wizard behavior. ClusterStatus and Membership
are stubbed pending TDD cycles.
Add ModulePath() to kiviktest.deps for Go 1.24+ compatibility. Fix unchecked
sql.Rows.Close() return values in longpollDBUpdates. Extend ClusterSetup to
treat finish_cluster identically to enable_single_node, and no-op for
enable_cluster and add_node, allowing test harnesses using the multi-node
setup flow to work against SQLite.
Returns "cluster_disabled" before ClusterSetup is called and
"single_node_enabled" after, by checking for the _global_changes table.
Reports "sqlite@localhost" in both all_nodes and cluster_nodes,
matching CouchDB's name@host format for Erlang distributed nodes.
Adds logGlobalChange which inserts an append-only document into
_global_changes within the CreateDB transaction, silently no-oping
when _global_changes tables are absent (pre-ClusterSetup state).
Refactors resolveSince to return (since, hasSince, err) for clarity.
Adds logGlobalChange call in DestroyDB alongside logDBUpdate so that
database deletions are recorded in _global_changes when ClusterSetup
has been run. Refactors test to use setup callbacks per testy convention.
Introduces testClient(t) in common_test.go to replace the repeated
drv{}.NewClient(":memory:", mock.NilOption) pattern across all sqlite
test files, reducing boilerplate and making setup intent clearer.
Guards DBUpdates with a _global_changes existence check so callers get
a meaningful 503 before ClusterSetup is run. Old kivik$db_updates_log
tests are skipped with TODOs pending removal in Cycle 5.
Replace kivik$db_updates_log queries with a globalChangesDBUpdates adapter
that wraps the _global_changes Changes feed. Reorder systemDatabases so
_global_changes is created first, enabling _users/_replicator events to be
logged during ClusterSetup.
Delete ensureDBUpdatesLog, logDBUpdate, longpollDBUpdates, the DBUpdatesLog
template func, and the schema entry — all dead code now that DBUpdates reads
from _global_changes/_changes.
Forward feed/since options to the underlying Changes call and default
since=now for longpoll/continuous feeds. Un-skip the longpoll test
now that the old kivik$db_updates_log has been removed.
Call ClusterSetup in the test setup so _global_changes exists, configure
AllDBs.expected for the three system databases, and remove DBUpdates.skip.
Tests now use ClusterSetup so _global_changes exists, and expected sequences
reflect _users(1) and _replicator(2) being logged before user-created databases.
Previously, feed=longpoll only routed to newLongpollChanges when since=now.
With an explicit since=<seq> at the current tip (no new records to return),
the feed fell through to newNormalChanges and returned EOF immediately instead
of blocking for the next change.
…DBChanges_longpoll

Five separate test functions shared identical structure (goroutine trigger after
delay, timing assertion, result check) and are cleaner as a single table.
…tabases

Replace the MD5-of-test-name DSN in testClient/newDB with an atomic
counter, ensuring every call gets a distinct named shared-memory database.
Parallel test runs (count>1, shuffle) with the same test name no longer
collide, and the underlying sql.DB is closed in cleanup so the named
database is released between runs.
@flimzy flimzy merged commit 33c3b16 into main Feb 18, 2026
18 checks passed
@flimzy flimzy deleted the sqlite44 branch February 18, 2026 20:41
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