From 412f7457bbc55940aeb52eff428eeb5d85f43553 Mon Sep 17 00:00:00 2001 From: Julius Henke Date: Wed, 20 May 2026 18:45:16 +0200 Subject: [PATCH] fix: make complete family update transactional This mitigates an issue where previous family data would be cleared, while the later update of the families might not pass leaving it in a state with empty family data. --- .../kotlin/org/tormap/service/RelayDetailsUpdateService.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/main/kotlin/org/tormap/service/RelayDetailsUpdateService.kt b/backend/src/main/kotlin/org/tormap/service/RelayDetailsUpdateService.kt index e86b2a20..d4b641a9 100644 --- a/backend/src/main/kotlin/org/tormap/service/RelayDetailsUpdateService.kt +++ b/backend/src/main/kotlin/org/tormap/service/RelayDetailsUpdateService.kt @@ -2,6 +2,7 @@ package org.tormap.service import org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer import org.springframework.stereotype.Service +import org.springframework.transaction.support.TransactionTemplate import org.tormap.database.entity.RelayDetails import org.tormap.database.repository.RelayDetailsRepositoryImpl import org.tormap.util.addFamilyMember @@ -11,7 +12,6 @@ import org.tormap.util.logger import javax.sql.DataSource import javax.transaction.Transactional - /** * This service deals with [RelayDetails] entities */ @@ -21,6 +21,7 @@ class RelayDetailsUpdateService( private val ipLookupService: IpLookupService, private val cacheService: CacheService, private val coalesceService: CoalesceService, + private val transactionTemplate: TransactionTemplate, dataSource: DataSource, ) { private val logger = logger() @@ -87,7 +88,9 @@ class RelayDetailsUpdateService( logger.info("... Updating relay families for months: {}", months.joinToString(", ")) months.forEach { month -> coalesceService.submitAsync("computeFamilies-$month") { - computeFamiliesForMonth(month) + transactionTemplate.executeWithoutResult { + computeFamiliesForMonth(month) + } } } }