Skip to content

Commit

Permalink
Made the TTLBufferDays configurable (uber#5354)
Browse files Browse the repository at this point in the history
  • Loading branch information
agautam478 authored Jul 24, 2023
1 parent 15f7fea commit 47f83ed
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions common/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,13 @@ const (
LargeShardHistoryBlobMetricThreshold
// LastIntKey must be the last one in this const group
LastIntKey

// TTLBufferDays are the buffer days added into the TTL time for security reasons.
// KeyName: system.TTLBufferDays
// Value type: Int
// Default value: 15
// Allowed filters: N/A
TTLBufferDays
)

const (
Expand Down Expand Up @@ -3623,6 +3630,11 @@ var IntKeys = map[IntKey]DynamicInt{
Description: "The number of attempts to push Isolation group configuration to the config store",
DefaultValue: 2,
},
TTLBufferDays: DynamicInt{
KeyName: "system.TTLBufferDays",
Description: "The number of buffer day in the TTL value",
DefaultValue: 15,
},
}

var BoolKeys = map[BoolKey]DynamicBool{
Expand Down
3 changes: 3 additions & 0 deletions config/dynamicconfig/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ history.EnableConsistentQueryByDomain:
system.enableExecutionTTL:
- value: true
constraints: {}
system.TTLBufferDays:
- value: 15
constraints: {}
history.enableCrossClusterOperations:
- value: true
constraints: {}
Expand Down
6 changes: 5 additions & 1 deletion service/history/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ type Config struct {

// HostName for machine running the service
HostName string

//TTLBufferdays values for the TTL on workflows.
TTLBufferDays dynamicconfig.IntPropertyFn
}

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

HostName: hostname,
HostName: hostname,
TTLBufferDays: dc.GetIntProperty(dynamicconfig.TTLBufferDays),
}

return cfg
Expand Down
1 change: 0 additions & 1 deletion service/history/execution/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (

const (
defaultRemoteCallTimeout = 30 * time.Second
ttlBufferDays = 15
dayToSecondMultiplier = 86400
)

Expand Down
2 changes: 1 addition & 1 deletion service/history/execution/mutable_state_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4823,7 +4823,7 @@ func (e *mutableStateBuilder) calculateTTL() (int, error) {
}
config := domainObj.GetConfig()
retention := time.Duration(config.Retention)
daysInSeconds := int((retention + ttlBufferDays) * dayToSecondMultiplier)
daysInSeconds := int(retention) + e.config.TTLBufferDays()*dayToSecondMultiplier
//Default state of TTL, means there is no TTL attached.
TTLInSeconds := 0
startTime := e.executionInfo.StartTimestamp
Expand Down

0 comments on commit 47f83ed

Please sign in to comment.