Skip to content

Comments

dynamic config: enhance update with metrics etc#9366

Open
feiyang3cat wants to merge 2 commits intotemporalio:mainfrom
feiyang3cat:dc/update-metric
Open

dynamic config: enhance update with metrics etc#9366
feiyang3cat wants to merge 2 commits intotemporalio:mainfrom
feiyang3cat:dc/update-metric

Conversation

@feiyang3cat
Copy link
Contributor

@feiyang3cat feiyang3cat commented Feb 19, 2026

What changed?

  1. added metric when update fails
  2. found a potential problem with lastModifiedTime, so enhanced its accuracy to of prevent cases like transient errors will skip next update, etc

Why?

may be a root cause why pods run into crashloop
adding this metric for alert make debugging easier

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

@feiyang3cat feiyang3cat requested review from a team as code owners February 19, 2026 22:04
@feiyang3cat feiyang3cat changed the title dynamic config: add metric dynamic config: enhance update with metrics etc Feb 19, 2026
tag.Bool("debug-mode", debug.Enabled),
)

metricsHandler, err := metrics.MetricsHandlerFromConfig(logger, cfg.Global.Metrics)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is kind of unfortunate. I would rather see main() use fewer ServerOptions and rely on the defaults more, instead of the opposite. Do you think you could look into what it would take to move initialization of both metrics handler and dc client out of main and use the defaults?

Copy link
Contributor Author

@feiyang3cat feiyang3cat Feb 19, 2026

Choose a reason for hiding this comment

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

Definitely! I'd love to look into it. I will follow this in another task. so that this refinement doesn't impact a fix

Copy link
Member

Choose a reason for hiding this comment

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

yeah I took a quick look and it's not clear to me why dynamicConfigClient need to be initialized here. The dc client config is available in temporal.NewServer as well.

Please add a TODO here.

fc.lastUpdatedTime = modtime
defer func() {
if updateErr != nil {
fc.lastUpdatedTime = prevModtime
Copy link
Contributor

Choose a reason for hiding this comment

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

this would be cleaner if it updated forward in the defer in the no-error case

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the current eager update is functioning as a kind of mutex for racers?

Copy link
Member

Choose a reason for hiding this comment

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

I am confused, why do we need to revert the value? If a file with ModTime = X is invalid, then there's no point re-processing it periodically right, until it's updated again? lastUpdatedTime is probably not a good name, it's more like lastCheckedFileModTime

Also don't see race condition here, there's only one goroutine checking and updating this field.

tag.Bool("debug-mode", debug.Enabled),
)

metricsHandler, err := metrics.MetricsHandlerFromConfig(logger, cfg.Global.Metrics)
Copy link
Member

Choose a reason for hiding this comment

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

yeah I took a quick look and it's not clear to me why dynamicConfigClient need to be initialized here. The dc client config is available in temporal.NewServer as well.

Please add a TODO here.

lastUpdatedTime time.Time
config *FileBasedClientConfig
doneCh <-chan any
handler metrics.Handler
Copy link
Member

Choose a reason for hiding this comment

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

plz, fc.handler is a bit confusing.

Suggested change
handler metrics.Handler
metricsHandler metrics.Handler

fc.lastUpdatedTime = modtime
defer func() {
if updateErr != nil {
fc.lastUpdatedTime = prevModtime
Copy link
Member

Choose a reason for hiding this comment

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

I am confused, why do we need to revert the value? If a file with ModTime = X is invalid, then there's no point re-processing it periodically right, until it's updated again? lastUpdatedTime is probably not a good name, it's more like lastCheckedFileModTime

Also don't see race condition here, there's only one goroutine checking and updating this field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants