Skip to content

MySQL document + projection stores - #8

Open
horner wants to merge 3 commits into
mainfrom
feat/mysql-stores
Open

MySQL document + projection stores#8
horner wants to merge 3 commits into
mainfrom
feat/mysql-stores

Conversation

@horner

@horner horner commented Aug 25, 2026

Copy link
Copy Markdown
Member

Drizzle-backed MySQL stores for yorm documents and projections, plus resilience: the pool retires idle connections before the server's wait_timeout kills them (idleTimeout/maxIdle/keepalive), ending PROTOCOL_CONNECTION_LOST 500s on websocket room opens.

Dogfooded in mieweb/eCase, which pins this branch as a submodule.

horner added 3 commits August 18, 2026 01:01
@yorm/drizzle shipped SQLite only. This adds a mysql2-backed pair behind the
same contracts, validated by the adapter conformance suite.

- schema-mysql.ts mirrors the SQLite system tables (varchar(191) keys so
  composite PKs fit InnoDB's index limit; datetime(3) round-trips exactly;
  longblob via customType, mysql-core has no blob column)
- projection-store/shared.ts extracts everything dialect-agnostic so the two
  stores differ only in their upsert and reconcile SQL
- the upsert uses ON DUPLICATE KEY UPDATE with VALUES(col) rather than MySQL
  8.0.19's AS-new row alias, which MariaDB does not have
- AdapterFactory gains sampleDdl: MySQL cannot put a primary key on TEXT
- resolveBackend now resolves mysql and mariadb

The MySQL suite runs when YORM_MYSQL_URL points at a server and skips otherwise.
yjs, hono and fhir use setTimeout, crypto and friends but got their Node types
from the workspace root's devDependencies. That works when yorm is its own
workspace and nowhere else: consumed as workspace members by another repo,
`tsc -b` fails with "Cannot find name 'setTimeout'".

A package that uses Node globals should say so.
…tions

Idle pool connections killed server-side by wait_timeout stayed in the
pool and failed their next query with PROTOCOL_CONNECTION_LOST, which
500'd websocket room opens until every stale connection was burned.
Retire idles client-side (idleTimeout 60s, maxIdle 2) and enable TCP
keepalive so the survivors stay healthy.
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