Skip to content

Declare SqlEventLogServerEncrypted indexes inline on SQL Server - #10675

Merged
tim-smart merged 4 commits into
Effect-TS:mainfrom
tylergibbs1:fix-eventlog-mssql-inline-indexes
Nov 17, 2026
Merged

tim-smart merged 4 commits into
Effect-TS:mainfrom
tylergibbs1:fix-eventlog-mssql-inline-indexes

Conversation

@tylergibbs1

@tylergibbs1 tylergibbs1 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Type

  • Bug Fix

Description

On SQL Server, concurrent openers of SqlEventLogServerEncrypted can both pass the index-existence check and execute separate CREATE INDEX statements, causing lock waits and deadlocks before retry recovery.

Declare the compaction-table indexes inside CREATE TABLE, matching the existing per-scope batch-table approach. Index names, columns and retries are unchanged. The change is MSSQL-local; MySQL, PostgreSQL and SQLite are untouched.

One regression in the existing MSSQL integration file holds a separate index creation open on another connection and asserts that opening storage completes instead of waiting on a lock held by that session. The probe filters on the holding session's id, because SQL Server's own background sessions block each other in a fresh container. The test detects the blocking path. It is not a full deadlock reproduction or a guarantee that all concurrent startup is wait-free.

Validation

At b04ad2d, using SQL Server 2022 through local Podman with EFFECT_INTEGRATION_TESTS=1 and EFFECT_MSSQL_INTEGRATION_TESTS=1:

  • Red: the regression against the base implementation fails with expected 'waited' to equal 'opened' in 2 of 2 runs.
  • Green: the regression passes in 8 of 8 isolated runs and in all 5 runs of the complete MSSQL SqlEventLogServerEncrypted.integration.test.ts.
  • Three of those five complete runs passed all 28 tests. The other two failed only in existing shared-suite tests that this PR does not touch, on a host with a load average of about 25 on 16 cores: one run reported Test timed out in 5000ms for two tests, and one run failed a single test after 5.2 seconds (message not captured).
  • pnpm lint-fix, pnpm check (tsrs) and git diff --check pass, all through nix develop -c.

Other SQL dialect suites were not rerun because their implementation is unchanged. Standard PR CI disables MSSQL integration tests, so the local SQL Server runs above are what cover this change.

Original author's cross-dialect red/green evidence for the first PR head: workflow run.

Related

Closes #10672
Closes EFF-3849

createTable created each compaction index with a separate
IF NOT EXISTS (sys.indexes) CREATE INDEX after the CREATE TABLE. Two
instances opening the same store could run CREATE INDEX on the same table
together, which SQL Server can deadlock and only resolves after its lock
monitor picks a victim (up to about 5 s).

The indexes are now declared inside the one CREATE TABLE, through a helper
shared with MySQL, so the table and its indexes appear together. Index
names, columns and the existing retry are unchanged.

Closes Effect-TS#10672

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b04ad2d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-janitor effect-janitor Bot added the 4.0 label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.09 KB 40.09 KB 0.00 KB (0.00%)
basic.ts 7.31 KB 7.31 KB 0.00 KB (0.00%)
batching.ts 11.21 KB 11.21 KB 0.00 KB (0.00%)
brand.ts 7.00 KB 7.00 KB 0.00 KB (0.00%)
cache.ts 11.73 KB 11.73 KB 0.00 KB (0.00%)
config.ts 23.09 KB 23.09 KB 0.00 KB (0.00%)
differ.ts 22.20 KB 22.20 KB 0.00 KB (0.00%)
http-client.ts 27.45 KB 27.45 KB 0.00 KB (0.00%)
http-router.ts 37.59 KB 37.59 KB 0.00 KB (0.00%)
logger.ts 12.19 KB 12.19 KB 0.00 KB (0.00%)
metric.ts 9.65 KB 9.65 KB 0.00 KB (0.00%)
optic.ts 7.21 KB 7.21 KB 0.00 KB (0.00%)
pubsub.ts 16.21 KB 16.21 KB 0.00 KB (0.00%)
queue.ts 13.09 KB 13.09 KB 0.00 KB (0.00%)
schedule.ts 11.99 KB 11.99 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.29 KB 14.29 KB 0.00 KB (0.00%)
schema-binary.ts 42.48 KB 42.48 KB 0.00 KB (0.00%)
schema-class.ts 21.96 KB 21.96 KB 0.00 KB (0.00%)
schema-codegen.ts 30.70 KB 30.70 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.56 KB 30.56 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.26 KB 28.26 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.54 KB 15.54 KB 0.00 KB (0.00%)
schema-string.ts 12.50 KB 12.50 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.43 KB 16.43 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.63 KB 39.63 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.11 KB 21.11 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.28 KB 21.28 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.37 KB 21.37 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.42 KB 26.42 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.45 KB 21.45 KB 0.00 KB (0.00%)
schema.ts 21.05 KB 21.05 KB 0.00 KB (0.00%)
stm.ts 14.46 KB 14.46 KB 0.00 KB (0.00%)
stream.ts 10.56 KB 10.56 KB 0.00 KB (0.00%)

@tim-smart
tim-smart merged commit 5caf323 into Effect-TS:main Nov 17, 2026
15 of 16 checks passed

This branch is waiting to be deployed

1 waiting deployment
fork — b04ad2d2 Waiting Nov 16, 2026 by effect-bot via approval-gate #26430
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eventlog: SqlEventLogServerEncrypted on SQL Server can stall for seconds when two instances create the same index

3 participants