Skip to content

Warm the MySQL ready pool before EnsureTemplate returns - #12

Merged
bashhack merged 1 commit into
mainfrom
mysql-warmup
Oct 22, 2026
Merged

bashhack merged 1 commit into
mainfrom
mysql-warmup

Conversation

@bashhack

@bashhack bashhack commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Two of the three items from the limits discussion.

Warm-up by default. The first GOMAXPROCS tests of a package used to find an empty pool and clone on demand (~0.5–0.8 s each). EnsureTemplate now waits for the pool to fill once before returning: one round of parallel clones, paid once in TestMain, after which every test from the first takes a prepared database. WithReadyWarmup(false) skips the wait for anyone who wants tests to start immediately. A context that ends during the warm-up releases the template on the way out, with a test that proves nothing is left behind (256 clones against a 500 ms deadline).

What the clone deliberately skips, written down. Events (a scheduler job firing inside a test's clone would make the test nondeterministic) and grants (tests connect as the admin user); DEFINER clauses are dropped so objects belong to whoever runs the clone; a foreign key to a table in another database keeps pointing there. The package doc no longer claims templates are unavailable for MySQL.

The third item, MariaDB in CI, is its own PR next.

The first GOMAXPROCS tests of a package used to find an empty pool and
clone on demand. EnsureTemplate now waits for the pool to fill once,
which costs one round of parallel clones, so every test from the first
takes a prepared database; WithReadyWarmup(false) skips the wait. A ctx
that ends during the warm-up releases the template on the way out.

Also says, in the package and clone docs, what a clone deliberately does
not copy: events (a scheduler job firing inside a test's clone would make
it nondeterministic) and grants (tests connect as the admin user); that
DEFINER clauses are dropped; and that a foreign key to another database
keeps pointing there. The package doc no longer says templates are
unavailable.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mysql/pool.go 92.30% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@bashhack
bashhack merged commit 6133a55 into main Oct 22, 2026
1 check passed
@bashhack
bashhack deleted the mysql-warmup branch October 22, 2026 06:55
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.

2 participants