Skip to content

Commit 47f83ed

Browse files
authored
Made the TTLBufferDays configurable (cadence-workflow#5354)
1 parent 15f7fea commit 47f83ed

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

common/dynamicconfig/constants.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,13 @@ const (
14081408
LargeShardHistoryBlobMetricThreshold
14091409
// LastIntKey must be the last one in this const group
14101410
LastIntKey
1411+
1412+
// TTLBufferDays are the buffer days added into the TTL time for security reasons.
1413+
// KeyName: system.TTLBufferDays
1414+
// Value type: Int
1415+
// Default value: 15
1416+
// Allowed filters: N/A
1417+
TTLBufferDays
14111418
)
14121419

14131420
const (
@@ -3623,6 +3630,11 @@ var IntKeys = map[IntKey]DynamicInt{
36233630
Description: "The number of attempts to push Isolation group configuration to the config store",
36243631
DefaultValue: 2,
36253632
},
3633+
TTLBufferDays: DynamicInt{
3634+
KeyName: "system.TTLBufferDays",
3635+
Description: "The number of buffer day in the TTL value",
3636+
DefaultValue: 15,
3637+
},
36263638
}
36273639

36283640
var BoolKeys = map[BoolKey]DynamicBool{

config/dynamicconfig/development.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ history.EnableConsistentQueryByDomain:
1010
system.enableExecutionTTL:
1111
- value: true
1212
constraints: {}
13+
system.TTLBufferDays:
14+
- value: 15
15+
constraints: {}
1316
history.enableCrossClusterOperations:
1417
- value: true
1518
constraints: {}

service/history/config/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ type Config struct {
326326

327327
// HostName for machine running the service
328328
HostName string
329+
330+
//TTLBufferdays values for the TTL on workflows.
331+
TTLBufferDays dynamicconfig.IntPropertyFn
329332
}
330333

331334
// New returns new service config with default values
@@ -569,7 +572,8 @@ func New(dc *dynamicconfig.Collection, numberOfShards int, maxMessageSize int, s
569572
LargeShardHistoryEventMetricThreshold: dc.GetIntProperty(dynamicconfig.LargeShardHistoryEventMetricThreshold),
570573
LargeShardHistoryBlobMetricThreshold: dc.GetIntProperty(dynamicconfig.LargeShardHistoryBlobMetricThreshold),
571574

572-
HostName: hostname,
575+
HostName: hostname,
576+
TTLBufferDays: dc.GetIntProperty(dynamicconfig.TTLBufferDays),
573577
}
574578

575579
return cfg

service/history/execution/context.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import (
4545

4646
const (
4747
defaultRemoteCallTimeout = 30 * time.Second
48-
ttlBufferDays = 15
4948
dayToSecondMultiplier = 86400
5049
)
5150

service/history/execution/mutable_state_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4823,7 +4823,7 @@ func (e *mutableStateBuilder) calculateTTL() (int, error) {
48234823
}
48244824
config := domainObj.GetConfig()
48254825
retention := time.Duration(config.Retention)
4826-
daysInSeconds := int((retention + ttlBufferDays) * dayToSecondMultiplier)
4826+
daysInSeconds := int(retention) + e.config.TTLBufferDays()*dayToSecondMultiplier
48274827
//Default state of TTL, means there is no TTL attached.
48284828
TTLInSeconds := 0
48294829
startTime := e.executionInfo.StartTimestamp

0 commit comments

Comments
 (0)