diff --git a/grpc/grpc-operation-ledger-jpa/build.gradle b/grpc/grpc-operation-ledger-jpa/build.gradle index d032106..05d90ae 100644 --- a/grpc/grpc-operation-ledger-jpa/build.gradle +++ b/grpc/grpc-operation-ledger-jpa/build.gradle @@ -31,6 +31,14 @@ def sharedMigrationFileSources = tasks.register('sharedMigrationFileSources', Sy into(layout.buildDirectory.dir('generated/sources/sharedMigrationFiles/java')) } sourceSets.integrationTest.java.srcDir(sharedMigrationFileSources) +// The copy is not this build's to format: Spotless here would name the generated file, and its +// spotlessApply would rewrite only that copy, which the next Sync puts back (re-review 2026-11-03 +// round 6, RR6-03-04). The main build's persistence-jpa spotlessCheck formats the original. +spotless { + java { + targetExclude('build/generated/sources/sharedMigrationFiles/**') + } +} // Durable mutation idempotency: the operation ledger entity, its state machine, the vendor-neutral // repository port and the Spring Data JPA binding, plus the migration that owns the unique diff --git a/grpc/grpc-operation-ledger-jpa/src/integrationTest/java/dev/caskeleton/grpc/ledger/GrpcOperationLedgerMigrationLockWaitIT.java b/grpc/grpc-operation-ledger-jpa/src/integrationTest/java/dev/caskeleton/grpc/ledger/GrpcOperationLedgerMigrationLockWaitIT.java index 1eaa9d0..723fe1d 100644 --- a/grpc/grpc-operation-ledger-jpa/src/integrationTest/java/dev/caskeleton/grpc/ledger/GrpcOperationLedgerMigrationLockWaitIT.java +++ b/grpc/grpc-operation-ledger-jpa/src/integrationTest/java/dev/caskeleton/grpc/ledger/GrpcOperationLedgerMigrationLockWaitIT.java @@ -29,10 +29,18 @@ import org.testcontainers.postgresql.PostgreSQLContainer; * *

A transaction that has written the ledger stays open for fifteen seconds — a claim in flight, * an operator's {@code BEGIN}. A write is the holder both migrations wait for: V003's ALTER TABLE - * would wait for a read too, V002's plain CREATE INDEX only for a write. The migration runs the way - * Flyway runs it, in one transaction. Unbounded it waits until the writer leaves, with every claim - * queued behind it, and then applies; bounded it fails with {@code lock_not_available} first and - * its rollback leaves the ledger as it was. + * would wait for a read too, V002's plain CREATE INDEX only for a write. The migration runs in one + * transaction, which is how Flyway runs the files this tree has: a {@code SET LOCAL lock_timeout} + * and statements that run in a transaction. Unbounded it waits until the writer leaves, with every + * claim queued behind it, and then applies; bounded it fails with {@code lock_not_available} first + * and its rollback leaves the ledger as it was. + * + *

A file Flyway runs outside a transaction — one holding {@code CREATE INDEX CONCURRENTLY} or + * another statement on Flyway's list, or with {@code executeInTransaction=false} beside it — is not + * one this test can judge: run here in a transaction, PostgreSQL refuses it ({@code 25001}), and no + * {@code SET LOCAL} would bound it in a deploy anyway. Name such a file as an exception in this + * test, and keep it alone in its migration ({@code docs/jpa/migration-guide.md}, "Concurrent index + * builds"; re-review 2026-11-03 round 6, RR6-03-05). * *

Every migration after V001 is held to this, read from the tree itself ({@link * GrpcOperationLedgerMigrations#inOrder()}), so a V004 is checked without anyone naming it here. @@ -46,6 +54,7 @@ import org.testcontainers.postgresql.PostgreSQLContainer; class GrpcOperationLedgerMigrationLockWaitIT { private static final String LOCK_NOT_AVAILABLE = "55P03"; + private static final String ACTIVE_SQL_TRANSACTION = "25001"; private static final Duration WRITER_STAYS = Duration.ofSeconds(15); private static final Duration GIVES_UP_WITHIN = Duration.ofSeconds(10); @@ -86,8 +95,14 @@ class GrpcOperationLedgerMigrationLockWaitIT { schema(statement))) .as( "%s must put SET LOCAL lock_timeout = '5s'; before it locks the ledger" - + " (docs/jpa/migration-guide.md, \"Bound the lock wait\")", - migration) + + " (docs/jpa/migration-guide.md, \"Bound the lock wait\")%s", + migration, + ACTIVE_SQL_TRANSACTION.equals(attempt.sqlState()) + ? ". PostgreSQL refused it inside a transaction (25001): Flyway runs such a file" + + " outside one, where SET LOCAL bounds nothing, so it is no case for this" + + " test. Keep it alone in its migration and name it as an exception here" + + " (\"Concurrent index builds\")" + : "") .containsExactly(LOCK_NOT_AVAILABLE, true, schemaBefore); } }