Skip to content

Weasel 9.23.0

Choose a tag to compare

@jeremydmiller jeremydmiller released this 31 Jul 21:31

Two concurrency/correctness fixes, plus the JasperFx 2.37.0 floor that was staged in 9.22.0 but never shipped — so 9.23.0 carries all three.

SqlServerMigrator.EnsureDatabaseExistsAsync is safe under concurrent callers (#415)

The check-then-create against master left the loser of the race holding SqlException 1801 — "Database 'x' already exists", and the method returned before the newly created database would accept logins. Neither mattered while a single process bootstrapped a single database at startup; both matter as soon as parallel test workers each provision their own database against a cold container.

  • 1801 is caught and treated as success. IF DB_ID(...) IS NULL CREATE DATABASE narrows the window but SQL Server does not make that pair atomic, so the catch is what closes it.
  • The method now waits until the database actually accepts a connection — unconditionally, since a concurrent creator leaves the same window open. When it returns, the database exists and is reachable.
  • The wait is bounded and expires loudly with a TimeoutException naming the database, and is configurable via DatabaseAvailabilityTimeout (default 30s) and DatabaseAvailabilityPollingInterval (default 1s). TimeSpan.Zero fails fast.
  • ] in a database name is escaped.
  • PostgresqlMigrator.EnsureDatabaseExistsAsync got the matching 42P04 duplicate_database catch. It needs no availability wait — Postgres accepts connections to a new database as soon as CREATE DATABASE returns.

This promotes logic that already existed in SqlServerDatabaseBootstrap in the EF Core test project into the shipped assembly; that helper now delegates.

AssertValidIdentifier rejects " and ; (#416)

Closes out the identifier half of #416, whose literal-escaping half shipped in 9.21.1. PostgresqlMigrator.AssertValidIdentifier is the only identifier check in the stack — DbObjectName and PostgresqlObjectName do no validation — yet it permitted the two characters that let an object name escape the statement it is written into: " closes a quoted identifier, and ; starts a new statement. It also now rejects all whitespace rather than just the literal space, so a newline cannot introduce a -- comment.

PostgresqlIdentifierInvalidException gained a constructor that names the rule that was broken; the existing one is untouched. DbObjectName and PostgresqlObjectName are now documented as not being sanitizing boundaries.

Dependencies

  • JasperFx floor raised to 2.37.0 (#417).

Full changelog: V9.21.0...V9.23.0