From 74212d64857441f437835f6d46b5a7a60565580c Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:43:02 +0200 Subject: [PATCH 1/3] BUGFIX: Specific exception if `updateAndReleaseLock` is called after rollback --- .../Classes/Infrastructure/DbalCheckpointStorage.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Neos.ContentRepository.Core/Classes/Infrastructure/DbalCheckpointStorage.php b/Neos.ContentRepository.Core/Classes/Infrastructure/DbalCheckpointStorage.php index d9d00aaccf7..a5f7ffe6442 100644 --- a/Neos.ContentRepository.Core/Classes/Infrastructure/DbalCheckpointStorage.php +++ b/Neos.ContentRepository.Core/Classes/Infrastructure/DbalCheckpointStorage.php @@ -115,6 +115,9 @@ public function updateAndReleaseLock(SequenceNumber $sequenceNumber): void if (!$this->connection->isTransactionActive()) { throw new \RuntimeException(sprintf('Failed to update and commit checkpoint for subscriber "%s" because no transaction is active', $this->subscriberId), 1652279314); } + if ($this->connection->isRollbackOnly()) { + throw new \RuntimeException(sprintf('Failed to update and commit checkpoint for subscriber "%s" because the transaction has been marked for rollback only', $this->subscriberId), 1711964313); + } try { if (!$this->lockedSequenceNumber->equals($sequenceNumber)) { $this->connection->update($this->tableName, ['appliedsequencenumber' => $sequenceNumber->value], ['subscriberid' => $this->subscriberId]); From 43b31f43c3df980caefb7970fef79588b1d5b259 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:43:59 +0200 Subject: [PATCH 2/3] TASK: Simplify error control flow in CatchUp::run --- Neos.ContentRepository.Core/Classes/Projection/CatchUp.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/Projection/CatchUp.php b/Neos.ContentRepository.Core/Classes/Projection/CatchUp.php index 962c8a1a46e..d3be3427a55 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/CatchUp.php +++ b/Neos.ContentRepository.Core/Classes/Projection/CatchUp.php @@ -121,11 +121,9 @@ public function run(EventStreamInterface $eventStream): SequenceNumber if ($this->onBeforeBatchCompletedHook) { ($this->onBeforeBatchCompletedHook)(); } - } catch (\Throwable $e) { + } finally { $this->checkpointStorage->updateAndReleaseLock($highestAppliedSequenceNumber); - throw $e; } - $this->checkpointStorage->updateAndReleaseLock($highestAppliedSequenceNumber); } return $highestAppliedSequenceNumber; } From e5d9595cca8135b44222a737c9cc69f4be1b8061 Mon Sep 17 00:00:00 2001 From: Marc Henry Schultz <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:34:18 +0200 Subject: [PATCH 3/3] TASK: CheckpointStorage refine rollback only error and link issue --- .../Classes/Infrastructure/DbalCheckpointStorage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Neos.ContentRepository.Core/Classes/Infrastructure/DbalCheckpointStorage.php b/Neos.ContentRepository.Core/Classes/Infrastructure/DbalCheckpointStorage.php index a5f7ffe6442..dac81690564 100644 --- a/Neos.ContentRepository.Core/Classes/Infrastructure/DbalCheckpointStorage.php +++ b/Neos.ContentRepository.Core/Classes/Infrastructure/DbalCheckpointStorage.php @@ -116,7 +116,8 @@ public function updateAndReleaseLock(SequenceNumber $sequenceNumber): void throw new \RuntimeException(sprintf('Failed to update and commit checkpoint for subscriber "%s" because no transaction is active', $this->subscriberId), 1652279314); } if ($this->connection->isRollbackOnly()) { - throw new \RuntimeException(sprintf('Failed to update and commit checkpoint for subscriber "%s" because the transaction has been marked for rollback only', $this->subscriberId), 1711964313); + // TODO as described in https://github.com/neos/neos-development-collection/issues/4970 we are in a bad state and cannot commit after a nested transaction was rolled back. + throw new \RuntimeException(sprintf('Failed to update and commit checkpoint for subscriber "%s" because the transaction has been marked for rollback only. See https://github.com/neos/neos-development-collection/issues/4970', $this->subscriberId), 1711964313); } try { if (!$this->lockedSequenceNumber->equals($sequenceNumber)) {