From 9d6a506f9ee0bbb31459d8a918344ff368e83c3b Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 5 Dec 2024 12:15:23 +0100 Subject: [PATCH] fix(backend): lock rows that are being streamed to pipeline (#3073) --- .../backend/service/submission/SubmissionDatabaseService.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt b/backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt index 2ae08ad2a..330a9de33 100644 --- a/backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt +++ b/backend/src/main/kotlin/org/loculus/backend/service/submission/SubmissionDatabaseService.kt @@ -34,6 +34,8 @@ import org.jetbrains.exposed.sql.stringLiteral import org.jetbrains.exposed.sql.stringParam import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update +import org.jetbrains.exposed.sql.vendors.ForUpdateOption.PostgreSQL.ForUpdate +import org.jetbrains.exposed.sql.vendors.ForUpdateOption.PostgreSQL.MODE import org.loculus.backend.api.AccessionVersion import org.loculus.backend.api.AccessionVersionInterface import org.loculus.backend.api.AccessionVersionOriginalMetadata @@ -163,6 +165,7 @@ class SubmissionDatabaseService( } .orderBy(table.accessionColumn) .limit(numberOfSequenceEntries) + .forUpdate(ForUpdate(mode = MODE.SKIP_LOCKED)) .fetchSize(streamBatchSize) .asSequence() .chunked(streamBatchSize)