From d78516d596830a52282a339778c81a967aa11eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Hern=C3=A1ndez?= Date: Sat, 26 Nov 2022 16:58:22 +0100 Subject: [PATCH] Fix a bug on scan operation due to Route53 results limit Set explicitly a limit of results from a Route53 query to the maximum number of items there could be on a table, to avoid pagination. Otherwise, there's a default of 100 which might produce invalid results (e.g. scanning resources of another table and reaching the limit, therefore not returning all results of the scanned table). --- .../com/ongres/labs/dyna53/route53/Route53Manager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dyna53/src/main/java/com/ongres/labs/dyna53/route53/Route53Manager.java b/src/dyna53/src/main/java/com/ongres/labs/dyna53/route53/Route53Manager.java index 9b62351..c0320cf 100644 --- a/src/dyna53/src/main/java/com/ongres/labs/dyna53/route53/Route53Manager.java +++ b/src/dyna53/src/main/java/com/ongres/labs/dyna53/route53/Route53Manager.java @@ -36,6 +36,11 @@ public class Route53Manager { private static final int MAX_VALUES_PER_RESOURCE_RECORD = 400; + private static final int MAX_RECORDS_HOSTED_ZONE = 10_000; + + // Max number of items on a table: max records minus SOA and NS for the zone minus a single table definition SRV + private static final int MAX_ITEMS_HOSTED_ZONE = MAX_RECORDS_HOSTED_ZONE - 2 - 1; + private static final Logger LOGGER = LoggerFactory.getLogger(Route53Manager.class); @ConfigProperty(name = "hosted_zone") @@ -51,7 +56,7 @@ void getZoneDomainNameFromHostedZone() { var getHostedZoneRequest = GetHostedZoneRequest.builder() .id(hostedZone) .build(); - + route53AsyncClient.getHostedZone(getHostedZoneRequest) .orTimeout(ROUTE53_API_CALLS_TIMEOUT_SECONDS, TimeUnit.SECONDS) .whenComplete( @@ -245,6 +250,7 @@ private Stream listAllRecords(RRType rrType) { return route53AsyncClient.listResourceRecordSets( ListResourceRecordSetsRequest.builder() .hostedZoneId(hostedZone) + .maxItems("" + MAX_ITEMS_HOSTED_ZONE) .startRecordType(rrType) // Surprisingly, if we don't include .startRecordName() we get a 400 - InvalidInputException .startRecordName(FIRST_LETTER_FIRST_POSSIBLE_LEXICOGRAPHICAL_DOMAIN_NAME_ROUTE53_ESCAPED)