From 6cce7c39a8163a78073239d4886f3e0ecacfcdd1 Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:19:23 +0000 Subject: [PATCH 1/2] Set garbage collection lambda timeout in seconds --- example/full/instance.properties | 4 ++-- .../java/sleeper/cdk/stack/GarbageCollectorStack.java | 4 ++-- .../instance/GarbageCollectionProperty.java | 8 ++++---- .../validation/SleeperPropertyValueUtils.java | 11 ----------- .../properties/instance/InstancePropertiesTest.java | 4 ++-- scripts/templates/instanceproperties.template | 4 ++-- 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/example/full/instance.properties b/example/full/instance.properties index fcb43f8937..c4c1746555 100644 --- a/example/full/instance.properties +++ b/example/full/instance.properties @@ -870,8 +870,8 @@ sleeper.default.partition.splitting.threshold=1000000000 # The frequency in minutes with which the garbage collector lambda is run. sleeper.gc.period.minutes=15 -# The configurable timeout wait in minutes for the garbage collector lambda. -sleeper.gc.lambda.timeout.minutes=14 +# The timeout in seconds for the garbage collector lambda. +sleeper.gc.lambda.timeout.seconds=840 # The amount of memory in MB for the lambda function used to perform garbage collection. sleeper.gc.memory.mb=4096 diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java index ae6dad8ea8..e6b3bef423 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java @@ -53,7 +53,7 @@ import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_CONCURRENCY_MAXIMUM; import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_CONCURRENCY_RESERVED; import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_MEMORY_IN_MB; -import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES; +import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS; import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_PERIOD_IN_MINUTES; import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_TABLE_BATCH_SIZE; import static sleeper.core.properties.instance.TableStateProperty.TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB; @@ -80,7 +80,7 @@ public GarbageCollectorStack( String triggerFunctionName = String.join("-", "sleeper", instanceId, "garbage-collector-trigger"); String functionName = String.join("-", "sleeper", instanceId, "garbage-collector"); - Duration handlerTimeout = Duration.seconds((60 * instanceProperties.getInt(GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES))); + Duration handlerTimeout = Duration.seconds(instanceProperties.getInt(GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS)); // Garbage collector function IFunction triggerFunction = lambdaCode.buildFunction(this, LambdaHandler.GARBAGE_COLLECTOR_TRIGGER, "GarbageCollectorTrigger", builder -> builder diff --git a/java/core/src/main/java/sleeper/core/properties/instance/GarbageCollectionProperty.java b/java/core/src/main/java/sleeper/core/properties/instance/GarbageCollectionProperty.java index 5b9cead44a..7dec74b320 100644 --- a/java/core/src/main/java/sleeper/core/properties/instance/GarbageCollectionProperty.java +++ b/java/core/src/main/java/sleeper/core/properties/instance/GarbageCollectionProperty.java @@ -34,11 +34,11 @@ public interface GarbageCollectionProperty { .defaultValue("15") .propertyGroup(InstancePropertyGroup.GARBAGE_COLLECTOR) .runCdkDeployWhenChanged(true).build(); - UserDefinedInstanceProperty GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES = Index.propertyBuilder("sleeper.gc.lambda.timeout.minutes") - .description("The configurable timeout wait in minutes for the garbage collector lambda.") - .defaultValue("14") + UserDefinedInstanceProperty GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.gc.lambda.timeout.seconds") + .description("The timeout in seconds for the garbage collector lambda.") + .defaultValue("840") + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .propertyGroup(InstancePropertyGroup.GARBAGE_COLLECTOR) - .validationPredicate(SleeperPropertyValueUtils::isPositiveIntegerLtEq15) .runCdkDeployWhenChanged(true).build(); UserDefinedInstanceProperty GARBAGE_COLLECTOR_LAMBDA_MEMORY_IN_MB = Index.propertyBuilder("sleeper.gc.memory.mb") .description("The amount of memory in MB for the lambda function used to perform garbage collection.") diff --git a/java/core/src/main/java/sleeper/core/properties/validation/SleeperPropertyValueUtils.java b/java/core/src/main/java/sleeper/core/properties/validation/SleeperPropertyValueUtils.java index 896f8a454a..e9cd17f643 100644 --- a/java/core/src/main/java/sleeper/core/properties/validation/SleeperPropertyValueUtils.java +++ b/java/core/src/main/java/sleeper/core/properties/validation/SleeperPropertyValueUtils.java @@ -77,17 +77,6 @@ public static boolean isPositiveIntegerLtEq10(String integer) { return parseAndCheckInteger(integer, num -> num > 0 && num <= 10); } - /** - * Checks if a property value is a whole positive number of minutes within the maximum timeout for an invocation of - * AWS Lambda. - * - * @param integer the value - * @return true if the value meets the requirement - */ - public static boolean isPositiveIntegerLtEq15(String integer) { - return parseAndCheckInteger(integer, num -> num > 0 && num <= 15); - } - /** * Checks if a property value is an integer greater than or equal to 0. * diff --git a/java/core/src/test/java/sleeper/core/properties/instance/InstancePropertiesTest.java b/java/core/src/test/java/sleeper/core/properties/instance/InstancePropertiesTest.java index 1f640376c5..31436dfe97 100644 --- a/java/core/src/test/java/sleeper/core/properties/instance/InstancePropertiesTest.java +++ b/java/core/src/test/java/sleeper/core/properties/instance/InstancePropertiesTest.java @@ -80,7 +80,7 @@ import static sleeper.core.properties.instance.CompactionProperty.MAXIMUM_CONCURRENT_COMPACTION_TASKS; import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_CONCURRENCY_RESERVED; import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_MEMORY_IN_MB; -import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES; +import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS; import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_PERIOD_IN_MINUTES; import static sleeper.core.properties.instance.IngestProperty.ECR_INGEST_REPO; import static sleeper.core.properties.instance.IngestProperty.INGEST_KEEP_ALIVE_PERIOD_IN_SECONDS; @@ -268,7 +268,7 @@ private static InstanceProperties getSleeperProperties() { instanceProperties.set(VPC_ID, "aVPC"); instanceProperties.set(SUBNETS, "subnet1"); instanceProperties.setNumber(GARBAGE_COLLECTOR_PERIOD_IN_MINUTES, 20); - instanceProperties.setNumber(GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES, 15); + instanceProperties.setNumber(GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS, 840); instanceProperties.setNumber(QUEUE_VISIBILITY_TIMEOUT_IN_SECONDS, 600); instanceProperties.setNumber(COMPACTION_KEEP_ALIVE_PERIOD_IN_SECONDS, 700); instanceProperties.setNumber(INGEST_KEEP_ALIVE_PERIOD_IN_SECONDS, 800); diff --git a/scripts/templates/instanceproperties.template b/scripts/templates/instanceproperties.template index 5721f86644..1f02110ddf 100644 --- a/scripts/templates/instanceproperties.template +++ b/scripts/templates/instanceproperties.template @@ -899,8 +899,8 @@ sleeper.default.partition.splitting.threshold=1000000000 # The frequency in minutes with which the garbage collector lambda is run. sleeper.gc.period.minutes=15 -# The configurable timeout wait in minutes for the garbage collector lambda. -sleeper.gc.lambda.timeout.minutes=14 +# The timeout in seconds for the garbage collector lambda. +sleeper.gc.lambda.timeout.seconds=840 # The amount of memory in MB for the lambda function used to perform garbage collection. sleeper.gc.memory.mb=4096 From df02e1ae47a01134e5f6c6379016b2f3712aa31e Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:19:42 +0000 Subject: [PATCH 2/2] Apply validation consistently for lambda timeout properties --- .../sleeper/core/properties/instance/BatcherProperty.java | 2 ++ .../properties/instance/PartitionSplittingProperty.java | 2 ++ .../sleeper/core/properties/instance/QueryProperty.java | 1 + .../core/properties/instance/TableStateProperty.java | 6 +++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/java/core/src/main/java/sleeper/core/properties/instance/BatcherProperty.java b/java/core/src/main/java/sleeper/core/properties/instance/BatcherProperty.java index f010145fef..e76c6d7dc3 100644 --- a/java/core/src/main/java/sleeper/core/properties/instance/BatcherProperty.java +++ b/java/core/src/main/java/sleeper/core/properties/instance/BatcherProperty.java @@ -33,6 +33,7 @@ public interface BatcherProperty { UserDefinedInstanceProperty INGEST_BATCHER_SUBMITTER_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.ingest.batcher.submitter.timeout.seconds") .description("The timeout in seconds for the lambda that receives submitted requests to ingest files.") .defaultValue("20") + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .propertyGroup(InstancePropertyGroup.INGEST) .runCdkDeployWhenChanged(true).build(); UserDefinedInstanceProperty INGEST_BATCHER_JOB_CREATION_MEMORY_IN_MB = Index.propertyBuilder("sleeper.ingest.batcher.job.creation.memory.mb") @@ -43,6 +44,7 @@ public interface BatcherProperty { UserDefinedInstanceProperty INGEST_BATCHER_JOB_CREATION_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.ingest.batcher.job.creation.timeout.seconds") .description("The timeout in seconds for the lambda that creates ingest jobs from submitted file ingest requests.") .defaultValue("900") + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .propertyGroup(InstancePropertyGroup.INGEST) .runCdkDeployWhenChanged(true).build(); UserDefinedInstanceProperty INGEST_BATCHER_JOB_CREATION_LAMBDA_PERIOD_IN_MINUTES = Index.propertyBuilder("sleeper.ingest.batcher.job.creation.period.minutes") diff --git a/java/core/src/main/java/sleeper/core/properties/instance/PartitionSplittingProperty.java b/java/core/src/main/java/sleeper/core/properties/instance/PartitionSplittingProperty.java index a23797225b..71b3f8a5c9 100644 --- a/java/core/src/main/java/sleeper/core/properties/instance/PartitionSplittingProperty.java +++ b/java/core/src/main/java/sleeper/core/properties/instance/PartitionSplittingProperty.java @@ -56,6 +56,7 @@ public interface PartitionSplittingProperty { UserDefinedInstanceProperty FIND_PARTITIONS_TO_SPLIT_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.partition.splitting.finder.timeout.seconds") .description("The timeout in seconds for the lambda function used to identify partitions that need to be split.") .defaultValue("900") + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .propertyGroup(InstancePropertyGroup.PARTITION_SPLITTING) .runCdkDeployWhenChanged(true).build(); UserDefinedInstanceProperty FIND_PARTITIONS_TO_SPLIT_LAMBDA_CONCURRENCY_RESERVED = Index.propertyBuilder("sleeper.partition.splitting.finder.concurrency.reserved") @@ -76,6 +77,7 @@ public interface PartitionSplittingProperty { UserDefinedInstanceProperty SPLIT_PARTITIONS_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.partition.splitting.timeout.seconds") .description("The timeout in seconds for the lambda function used to split partitions.") .defaultValue("900") + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .propertyGroup(InstancePropertyGroup.PARTITION_SPLITTING) .runCdkDeployWhenChanged(true).build(); UserDefinedInstanceProperty SPLIT_PARTITIONS_RESERVED_CONCURRENCY = Index.propertyBuilder("sleeper.partition.splitting.reserved.concurrency") diff --git a/java/core/src/main/java/sleeper/core/properties/instance/QueryProperty.java b/java/core/src/main/java/sleeper/core/properties/instance/QueryProperty.java index db433d59d9..a6b6c516c4 100644 --- a/java/core/src/main/java/sleeper/core/properties/instance/QueryProperty.java +++ b/java/core/src/main/java/sleeper/core/properties/instance/QueryProperty.java @@ -41,6 +41,7 @@ public interface QueryProperty { UserDefinedInstanceProperty QUERY_PROCESSOR_LAMBDA_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.query.processor.timeout.seconds") .description("The timeout for the lambda that executes queries in seconds.") .defaultValue("900") + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .propertyGroup(InstancePropertyGroup.QUERY) .runCdkDeployWhenChanged(true).build(); UserDefinedInstanceProperty QUERY_PROCESSING_LAMBDA_STATE_REFRESHING_PERIOD_IN_SECONDS = Index.propertyBuilder("sleeper.query.processor.state.refresh.period.seconds") diff --git a/java/core/src/main/java/sleeper/core/properties/instance/TableStateProperty.java b/java/core/src/main/java/sleeper/core/properties/instance/TableStateProperty.java index d3914ce9d3..9623141dc4 100644 --- a/java/core/src/main/java/sleeper/core/properties/instance/TableStateProperty.java +++ b/java/core/src/main/java/sleeper/core/properties/instance/TableStateProperty.java @@ -66,7 +66,7 @@ private static UserDefinedInstancePropertyImpl.Builder propertyBuilder(String pr .description("The timeout in seconds for lambdas that create batches of tables to run some operation against, " + "eg. create compaction jobs, run garbage collection, perform partition splitting.") .defaultValue("60") - .validationPredicate(SleeperPropertyValueUtils::isPositiveInteger) + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .propertyGroup(InstancePropertyGroup.TABLE_STATE) .build(); UserDefinedInstanceProperty TABLE_PROPERTIES_PROVIDER_TIMEOUT_IN_MINS = Index.propertyBuilder("sleeper.cache.table.properties.provider.timeout.minutes") @@ -112,7 +112,7 @@ private static UserDefinedInstancePropertyImpl.Builder propertyBuilder(String pr UserDefinedInstanceProperty SNAPSHOT_CREATION_LAMBDA_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.statestore.snapshot.creation.lambda.timeout.seconds") .description("The timeout in seconds after which to terminate the transaction log snapshot creation lambda.") .defaultValue("900") - .validationPredicate(SleeperPropertyValueUtils::isPositiveInteger) + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .propertyGroup(InstancePropertyGroup.TABLE_STATE) .build(); UserDefinedInstanceProperty SNAPSHOT_CREATION_LAMBDA_MEMORY = Index.propertyBuilder("sleeper.statestore.snapshot.creation.memory.mb") @@ -178,7 +178,7 @@ private static UserDefinedInstancePropertyImpl.Builder propertyBuilder(String pr .propertyGroup(InstancePropertyGroup.TABLE_STATE).build(); UserDefinedInstanceProperty TRANSACTION_DELETION_LAMBDA_TIMEOUT_SECS = Index.propertyBuilder("sleeper.statestore.transaction.deletion.lambda.timeout.seconds") .description("The maximum timeout for the transaction deletion lambda in seconds.") - .validationPredicate(SleeperPropertyValueUtils::isPositiveInteger) + .validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout) .defaultValue("900") .propertyGroup(InstancePropertyGroup.TABLE_STATE).build(); UserDefinedInstanceProperty TABLE_INDEX_DYNAMO_POINT_IN_TIME_RECOVERY = Index.propertyBuilder("sleeper.tables.index.dynamo.pointintimerecovery")