Skip to content

Commit

Permalink
Merge pull request #3927 from gchq/3909-lambda-timeout-seconds
Browse files Browse the repository at this point in the history
Issue 3909 - Configure GC lambda timeout in seconds
  • Loading branch information
patchwork01 authored Dec 13, 2024
2 parents cf08899 + df02e1a commit b46ccf1
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 26 deletions.
4 changes: 2 additions & 2 deletions example/full/instance.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions scripts/templates/instanceproperties.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b46ccf1

Please sign in to comment.