Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Set dynamic config values and default search attribute cache as disabled #136

Merged
merged 4 commits into from
Sep 23, 2022

Conversation

cretz
Copy link
Member

@cretz cretz commented Sep 21, 2022

What changed?

  • Added CLI and library support for setting individual dynamic config values
  • Defaulted CLI (with opt-out) and test server to disable search attribute cache

Why?

For use with search attributes, the dev-only setting to disable cache is needed or there is a wait period before the search attributes are available for use.

This further cements that Temporalite is not for production use. This is the same config as dev docker compose at https://github.com/temporalio/docker-compose/blob/7c4f708c579cd735145e49816750ca4368ff5bf3/dynamicconfig/development-sql.yaml#L5. Any concerns here?

cmd/temporalite/main_test.go Outdated Show resolved Hide resolved
Comment on lines 276 to 282
// If there is no config value for search attribute cache disabling,
// default it to true
if len(configVals[dynamicconfig.ForceSearchAttributesCacheRefreshOnRead]) == 0 {
configVals[dynamicconfig.ForceSearchAttributesCacheRefreshOnRead] = []dynamicconfig.ConstrainedValue{
{Value: true},
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This further cements that Temporalite is not for production use.

I'd love to ship "production ready" defaults as much as possible. Do we think that disabling this cache will be a limiting factor in terms of performance? Trading a small amount of runtime performance for no race conditions or startup wait time sounds fine to me, though we could also consider only enabling this in the temporaltest package if the runtime cost is high.

Copy link
Collaborator

@jlegrone jlegrone Sep 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also instead of setting a default here, I think we should probably do it inside temporalite.NewServer so that library users get the same behavior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had the same concerns but thought Temporalite was going for "development defaults" even in the CLI. I would be happy only setting this in temporaltest. Let me confirm with @bergundy who wanted this defauted in the CLI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think that having the temporalite "yolo" command for common test setup (includes --ephemeral too) is starting to make sense.

Copy link
Collaborator

@jlegrone jlegrone Sep 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO Temporalite values go something like this

  1. User experience (for development use cases)
  2. Security
  3. Performance
  4. Simplicity
  5. Configurability

So I'm very happy to trade off some performance for a better development experience. We can always add a --production flag to swap around a few defaults and keep things simple.

Another thought is that we could add flags to register search attributes at startup like we do for namespaces. This would essentially be the best of both worlds since we'd be able to ensure that each of those SAs is registered synchronously, without disabling caching completely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought is that we could add flags to register search attributes at startup like we do for namespaces. This would essentially be the best of both worlds since we'd be able to ensure that each of those SAs is registered synchronously, without disabling caching completely.

I'd rather users do this with the SDK so their tests can run against any server implementation without customization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed default from CLI

cmd/temporalite/main.go Outdated Show resolved Hide resolved
cmd/temporalite/main.go Show resolved Hide resolved
cmd/temporalite/main.go Show resolved Hide resolved
cmd/temporalite/main_test.go Outdated Show resolved Hide resolved
return nil, fmt.Errorf("dynamic config value not in KEY=JSON_VAL format")
}
key := dynamicconfig.Key(keyVal[0])
// We don't support constraints currently
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constraints sound nice... what are they and is there future work we should track to support them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know, I'd have to speak to the server team. My use case and most use cases I've seen don't have these constraints. We can block this PR for that if we really need to.

cmd/temporalite/main_test.go Show resolved Hide resolved
Comment on lines +134 to +141
// WithSearchAttributeCacheDisabled disables search attribute caching. This
// delegates to WithDynamicConfigValue.
func WithSearchAttributeCacheDisabled() ServerOption {
return WithDynamicConfigValue(
dynamicconfig.ForceSearchAttributesCacheRefreshOnRead,
[]dynamicconfig.ConstrainedValue{{Value: true}},
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented above, but should we make this the default and instead add an option for enabling the cache? We could comment to the effect of changing this default if/when we are able to remove the waiting period after registering search attributes, and if you need stable behavior use WithDynamicConfigValue.

Copy link
Member Author

@cretz cretz Sep 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be opt-in programmatically, like persistence-disabled, especially now that we are going to turn it off by default on the CLI. (will still use in temporaltest)

@jlegrone
Copy link
Collaborator

This lgtm if we turn off the SA cache in temporaltest only for now. For the record I'm open to making this the default behavior from the CLI in the future, but would love to see a benchmark comparing perf.

@cretz would you mind adding a note on dynamic config to the relevant section of the README as well?

@cretz
Copy link
Member Author

cretz commented Sep 23, 2022

I think some schedule-to-close is too aggressive for Windows in some tests causing flakes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants