Skip to content

Commit b46ccf1

Browse files
authored
Merge pull request #3927 from gchq/3909-lambda-timeout-seconds
Issue 3909 - Configure GC lambda timeout in seconds
2 parents cf08899 + df02e1a commit b46ccf1

File tree

10 files changed

+20
-26
lines changed

10 files changed

+20
-26
lines changed

example/full/instance.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,8 @@ sleeper.default.partition.splitting.threshold=1000000000
870870
# The frequency in minutes with which the garbage collector lambda is run.
871871
sleeper.gc.period.minutes=15
872872

873-
# The configurable timeout wait in minutes for the garbage collector lambda.
874-
sleeper.gc.lambda.timeout.minutes=14
873+
# The timeout in seconds for the garbage collector lambda.
874+
sleeper.gc.lambda.timeout.seconds=840
875875

876876
# The amount of memory in MB for the lambda function used to perform garbage collection.
877877
sleeper.gc.memory.mb=4096

java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_CONCURRENCY_MAXIMUM;
5454
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_CONCURRENCY_RESERVED;
5555
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_MEMORY_IN_MB;
56-
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES;
56+
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS;
5757
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_PERIOD_IN_MINUTES;
5858
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_TABLE_BATCH_SIZE;
5959
import static sleeper.core.properties.instance.TableStateProperty.TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB;
@@ -80,7 +80,7 @@ public GarbageCollectorStack(
8080
String triggerFunctionName = String.join("-", "sleeper", instanceId, "garbage-collector-trigger");
8181
String functionName = String.join("-", "sleeper", instanceId, "garbage-collector");
8282

83-
Duration handlerTimeout = Duration.seconds((60 * instanceProperties.getInt(GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES)));
83+
Duration handlerTimeout = Duration.seconds(instanceProperties.getInt(GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS));
8484

8585
// Garbage collector function
8686
IFunction triggerFunction = lambdaCode.buildFunction(this, LambdaHandler.GARBAGE_COLLECTOR_TRIGGER, "GarbageCollectorTrigger", builder -> builder

java/core/src/main/java/sleeper/core/properties/instance/BatcherProperty.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public interface BatcherProperty {
3333
UserDefinedInstanceProperty INGEST_BATCHER_SUBMITTER_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.ingest.batcher.submitter.timeout.seconds")
3434
.description("The timeout in seconds for the lambda that receives submitted requests to ingest files.")
3535
.defaultValue("20")
36+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
3637
.propertyGroup(InstancePropertyGroup.INGEST)
3738
.runCdkDeployWhenChanged(true).build();
3839
UserDefinedInstanceProperty INGEST_BATCHER_JOB_CREATION_MEMORY_IN_MB = Index.propertyBuilder("sleeper.ingest.batcher.job.creation.memory.mb")
@@ -43,6 +44,7 @@ public interface BatcherProperty {
4344
UserDefinedInstanceProperty INGEST_BATCHER_JOB_CREATION_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.ingest.batcher.job.creation.timeout.seconds")
4445
.description("The timeout in seconds for the lambda that creates ingest jobs from submitted file ingest requests.")
4546
.defaultValue("900")
47+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
4648
.propertyGroup(InstancePropertyGroup.INGEST)
4749
.runCdkDeployWhenChanged(true).build();
4850
UserDefinedInstanceProperty INGEST_BATCHER_JOB_CREATION_LAMBDA_PERIOD_IN_MINUTES = Index.propertyBuilder("sleeper.ingest.batcher.job.creation.period.minutes")

java/core/src/main/java/sleeper/core/properties/instance/GarbageCollectionProperty.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public interface GarbageCollectionProperty {
3434
.defaultValue("15")
3535
.propertyGroup(InstancePropertyGroup.GARBAGE_COLLECTOR)
3636
.runCdkDeployWhenChanged(true).build();
37-
UserDefinedInstanceProperty GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES = Index.propertyBuilder("sleeper.gc.lambda.timeout.minutes")
38-
.description("The configurable timeout wait in minutes for the garbage collector lambda.")
39-
.defaultValue("14")
37+
UserDefinedInstanceProperty GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.gc.lambda.timeout.seconds")
38+
.description("The timeout in seconds for the garbage collector lambda.")
39+
.defaultValue("840")
40+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
4041
.propertyGroup(InstancePropertyGroup.GARBAGE_COLLECTOR)
41-
.validationPredicate(SleeperPropertyValueUtils::isPositiveIntegerLtEq15)
4242
.runCdkDeployWhenChanged(true).build();
4343
UserDefinedInstanceProperty GARBAGE_COLLECTOR_LAMBDA_MEMORY_IN_MB = Index.propertyBuilder("sleeper.gc.memory.mb")
4444
.description("The amount of memory in MB for the lambda function used to perform garbage collection.")

java/core/src/main/java/sleeper/core/properties/instance/PartitionSplittingProperty.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public interface PartitionSplittingProperty {
5656
UserDefinedInstanceProperty FIND_PARTITIONS_TO_SPLIT_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.partition.splitting.finder.timeout.seconds")
5757
.description("The timeout in seconds for the lambda function used to identify partitions that need to be split.")
5858
.defaultValue("900")
59+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
5960
.propertyGroup(InstancePropertyGroup.PARTITION_SPLITTING)
6061
.runCdkDeployWhenChanged(true).build();
6162
UserDefinedInstanceProperty FIND_PARTITIONS_TO_SPLIT_LAMBDA_CONCURRENCY_RESERVED = Index.propertyBuilder("sleeper.partition.splitting.finder.concurrency.reserved")
@@ -76,6 +77,7 @@ public interface PartitionSplittingProperty {
7677
UserDefinedInstanceProperty SPLIT_PARTITIONS_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.partition.splitting.timeout.seconds")
7778
.description("The timeout in seconds for the lambda function used to split partitions.")
7879
.defaultValue("900")
80+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
7981
.propertyGroup(InstancePropertyGroup.PARTITION_SPLITTING)
8082
.runCdkDeployWhenChanged(true).build();
8183
UserDefinedInstanceProperty SPLIT_PARTITIONS_RESERVED_CONCURRENCY = Index.propertyBuilder("sleeper.partition.splitting.reserved.concurrency")

java/core/src/main/java/sleeper/core/properties/instance/QueryProperty.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public interface QueryProperty {
4141
UserDefinedInstanceProperty QUERY_PROCESSOR_LAMBDA_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.query.processor.timeout.seconds")
4242
.description("The timeout for the lambda that executes queries in seconds.")
4343
.defaultValue("900")
44+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
4445
.propertyGroup(InstancePropertyGroup.QUERY)
4546
.runCdkDeployWhenChanged(true).build();
4647
UserDefinedInstanceProperty QUERY_PROCESSING_LAMBDA_STATE_REFRESHING_PERIOD_IN_SECONDS = Index.propertyBuilder("sleeper.query.processor.state.refresh.period.seconds")

java/core/src/main/java/sleeper/core/properties/instance/TableStateProperty.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static UserDefinedInstancePropertyImpl.Builder propertyBuilder(String pr
6666
.description("The timeout in seconds for lambdas that create batches of tables to run some operation against, " +
6767
"eg. create compaction jobs, run garbage collection, perform partition splitting.")
6868
.defaultValue("60")
69-
.validationPredicate(SleeperPropertyValueUtils::isPositiveInteger)
69+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
7070
.propertyGroup(InstancePropertyGroup.TABLE_STATE)
7171
.build();
7272
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
112112
UserDefinedInstanceProperty SNAPSHOT_CREATION_LAMBDA_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.statestore.snapshot.creation.lambda.timeout.seconds")
113113
.description("The timeout in seconds after which to terminate the transaction log snapshot creation lambda.")
114114
.defaultValue("900")
115-
.validationPredicate(SleeperPropertyValueUtils::isPositiveInteger)
115+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
116116
.propertyGroup(InstancePropertyGroup.TABLE_STATE)
117117
.build();
118118
UserDefinedInstanceProperty SNAPSHOT_CREATION_LAMBDA_MEMORY = Index.propertyBuilder("sleeper.statestore.snapshot.creation.memory.mb")
@@ -178,7 +178,7 @@ private static UserDefinedInstancePropertyImpl.Builder propertyBuilder(String pr
178178
.propertyGroup(InstancePropertyGroup.TABLE_STATE).build();
179179
UserDefinedInstanceProperty TRANSACTION_DELETION_LAMBDA_TIMEOUT_SECS = Index.propertyBuilder("sleeper.statestore.transaction.deletion.lambda.timeout.seconds")
180180
.description("The maximum timeout for the transaction deletion lambda in seconds.")
181-
.validationPredicate(SleeperPropertyValueUtils::isPositiveInteger)
181+
.validationPredicate(SleeperPropertyValueUtils::isValidLambdaTimeout)
182182
.defaultValue("900")
183183
.propertyGroup(InstancePropertyGroup.TABLE_STATE).build();
184184
UserDefinedInstanceProperty TABLE_INDEX_DYNAMO_POINT_IN_TIME_RECOVERY = Index.propertyBuilder("sleeper.tables.index.dynamo.pointintimerecovery")

java/core/src/main/java/sleeper/core/properties/validation/SleeperPropertyValueUtils.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,6 @@ public static boolean isPositiveIntegerLtEq10(String integer) {
7777
return parseAndCheckInteger(integer, num -> num > 0 && num <= 10);
7878
}
7979

80-
/**
81-
* Checks if a property value is a whole positive number of minutes within the maximum timeout for an invocation of
82-
* AWS Lambda.
83-
*
84-
* @param integer the value
85-
* @return true if the value meets the requirement
86-
*/
87-
public static boolean isPositiveIntegerLtEq15(String integer) {
88-
return parseAndCheckInteger(integer, num -> num > 0 && num <= 15);
89-
}
90-
9180
/**
9281
* Checks if a property value is an integer greater than or equal to 0.
9382
*

java/core/src/test/java/sleeper/core/properties/instance/InstancePropertiesTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
import static sleeper.core.properties.instance.CompactionProperty.MAXIMUM_CONCURRENT_COMPACTION_TASKS;
8181
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_CONCURRENCY_RESERVED;
8282
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_MEMORY_IN_MB;
83-
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES;
83+
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS;
8484
import static sleeper.core.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_PERIOD_IN_MINUTES;
8585
import static sleeper.core.properties.instance.IngestProperty.ECR_INGEST_REPO;
8686
import static sleeper.core.properties.instance.IngestProperty.INGEST_KEEP_ALIVE_PERIOD_IN_SECONDS;
@@ -268,7 +268,7 @@ private static InstanceProperties getSleeperProperties() {
268268
instanceProperties.set(VPC_ID, "aVPC");
269269
instanceProperties.set(SUBNETS, "subnet1");
270270
instanceProperties.setNumber(GARBAGE_COLLECTOR_PERIOD_IN_MINUTES, 20);
271-
instanceProperties.setNumber(GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_MINUTES, 15);
271+
instanceProperties.setNumber(GARBAGE_COLLECTOR_LAMBDA_TIMEOUT_IN_SECONDS, 840);
272272
instanceProperties.setNumber(QUEUE_VISIBILITY_TIMEOUT_IN_SECONDS, 600);
273273
instanceProperties.setNumber(COMPACTION_KEEP_ALIVE_PERIOD_IN_SECONDS, 700);
274274
instanceProperties.setNumber(INGEST_KEEP_ALIVE_PERIOD_IN_SECONDS, 800);

scripts/templates/instanceproperties.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,8 @@ sleeper.default.partition.splitting.threshold=1000000000
899899
# The frequency in minutes with which the garbage collector lambda is run.
900900
sleeper.gc.period.minutes=15
901901

902-
# The configurable timeout wait in minutes for the garbage collector lambda.
903-
sleeper.gc.lambda.timeout.minutes=14
902+
# The timeout in seconds for the garbage collector lambda.
903+
sleeper.gc.lambda.timeout.seconds=840
904904

905905
# The amount of memory in MB for the lambda function used to perform garbage collection.
906906
sleeper.gc.memory.mb=4096

0 commit comments

Comments
 (0)