Use batched IN clause for GUID existence check during feed refresh

Instead of fetching all existing GUID hashes for a feed from the database only check the GUIDs present in the current feed XML using a SQL IN clause. GUIDs are partitioned into batches of 1000.

Also adds an integration test verifying that refreshing an up-to-date feed does not create duplicate entries.
This commit is contained in:
Ingo Kegel
2026-04-10 10:13:37 +02:00
parent 16036897cb
commit 1d23907652
3 changed files with 41 additions and 5 deletions

View File

@@ -30,6 +30,8 @@ class LargeDatasetIT extends BaseIT {
private static final int ENTRIES_PER_FEED = 20;
private static final int TOTAL_ENTRIES = FEED_COUNT * ENTRIES_PER_FEED;
private Long firstSubscriptionId;
@BeforeEach
void setup() {
initialSetup(TestConstants.ADMIN_USERNAME, TestConstants.ADMIN_PASSWORD);
@@ -39,7 +41,10 @@ class LargeDatasetIT extends BaseIT {
String path = "/feed/" + i;
getMockServerClient().when(HttpRequest.request().withMethod("GET").withPath(path))
.respond(HttpResponse.response().withBody(generateFeed(i)).withContentType(MediaType.APPLICATION_XML));
subscribe("http://localhost:" + getMockServerClient().getPort() + path);
Long subscriptionId = subscribe("http://localhost:" + getMockServerClient().getPort() + path);
if (i == 0) {
firstSubscriptionId = subscriptionId;
}
}
Awaitility.await().atMost(Duration.ofSeconds(60)).until(() -> getAllEntries().getEntries().size(), count -> count >= TOTAL_ENTRIES);
@@ -66,6 +71,18 @@ class LargeDatasetIT extends BaseIT {
Assertions.assertTrue(after.getEntries().stream().allMatch(Entry::isRead));
}
@Test
void refreshDoesNotCreateDuplicateEntries() {
Assertions.assertEquals(TOTAL_ENTRIES, getAllEntries().getEntries().size());
Instant threshold = Instant.now().minus(Duration.ofSeconds(1));
forceRefreshAllFeeds();
Awaitility.await()
.atMost(Duration.ofSeconds(15))
.until(() -> getSubscription(firstSubscriptionId), f -> f.getLastRefresh().isAfter(threshold));
Assertions.assertEquals(TOTAL_ENTRIES, getAllEntries().getEntries().size());
}
@Test
void paginationHasMore() {
Entries firstPage = RestAssured.given()