From c48ef696622a0aef5b753d88ccf798e195d44c9c Mon Sep 17 00:00:00 2001 From: eikek <701128+eikek@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:14:41 +0200 Subject: [PATCH] Reset lock documents on startup (#211) In the situation the services crashes or gets killed while a lock is being held, it would startup into an incorrect state. On startup, the lock documents are resetted to recover from such a case. This can be problematic when many services are deployed, because it would reset all documents right now. This will be addressed in a future change and for the currently foreseeable future, there will be only one instance. --- .../scala/io/renku/search/provision/Microservice.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/search-provision/src/main/scala/io/renku/search/provision/Microservice.scala b/modules/search-provision/src/main/scala/io/renku/search/provision/Microservice.scala index 599a2f88..a1c3a26e 100644 --- a/modules/search-provision/src/main/scala/io/renku/search/provision/Microservice.scala +++ b/modules/search-provision/src/main/scala/io/renku/search/provision/Microservice.scala @@ -44,8 +44,12 @@ object Microservice extends IOApp: logger .warn(s"There were ${migrateResult.migrationsSkipped} skipped migrations!") ) - // this is only safe for a single provisioning service - _ <- services.resetLockDocuments + // this is really only safe for a single provisioning service, + // but for the immediate future that is the situation. So do + // this to recover from crashes during a lock is held + _ <- services.resetLockDocuments.handleErrorWith { ex => + logger.warn(s"Resetting locks on start failed", ex) + } registryBuilder = CollectorRegistryBuilder[IO].withJVMMetrics .add(RedisMetrics.queueSizeGauge) .add(RedisMetrics.unprocessedGauge)