Skip to content

Strongly consistent Nexus endpoints lookup via dynamic config - #10208

Merged
stephanos merged 4 commits into
mainfrom
stephanos/sano-flaky-endpoint-2
May 15, 2026
Merged

stephanos merged 4 commits into
mainfrom
stephanos/sano-flaky-endpoint-2

Conversation

@stephanos

@stephanos stephanos commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

What changed?

Instead of using the cache for Nexus endpoint name lookups, always look it up via RPC when RefreshNexusEndpointsOnRead is set.

See #10204 for an alternative approach.

Why?

During testing - such as functional server tests or SDK tests against the CLI - the Nexus endpoint is not always immediately available after creation. This creates friction as it requires extra retries and causes flakiness if not guarded against. This change eliminates that need.

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)

@stephanos
stephanos force-pushed the stephanos/sano-flaky-endpoint-2 branch 2 times, most recently from a3edc65 to 6b82326 Compare May 8, 2026 23:11
@stephanos stephanos changed the title Stephanos/sano flaky endpoint 2 New RefreshNexusEndpointsOnRead dc May 8, 2026
@stephanos
stephanos force-pushed the stephanos/sano-flaky-endpoint-2 branch 2 times, most recently from fe97fdc to 619ca31 Compare May 8, 2026 23:15
Comment thread common/dynamicconfig/constants.go Outdated
@@ -959,6 +959,11 @@ and deployment interaction in matching and history.`,
1*time.Second,
`RefreshNexusEndpointsMinWait is the minimum wait time between background long poll requests to update Nexus endpoints.`,
)
RefreshNexusEndpointsOnReadForTest = NewGlobalBoolSetting(

@stephanos stephanos May 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Decided on ForTest suffix to make it very clear this is not for prod.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If it's not for prod, maybe it could be a test hook instead of dynamic config?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One of the uses cases is the embedded server inside the CLI, though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah it may not be for prod but end users will want to set this in the dev server

@stephanos stephanos changed the title New RefreshNexusEndpointsOnRead dc New RefreshNexusEndpointsOnReadForTest dc May 8, 2026
@stephanos stephanos changed the title New RefreshNexusEndpointsOnReadForTest dc Strongly consistent Nexus endpoints via dynamic config May 8, 2026
@stephanos
stephanos force-pushed the stephanos/sano-flaky-endpoint-2 branch from 619ca31 to 3146afa Compare May 8, 2026 23:20
@stephanos stephanos mentioned this pull request May 8, 2026
2 of 5 tasks
@stephanos
stephanos force-pushed the stephanos/sano-flaky-endpoint-2 branch from 3146afa to ace3ca5 Compare May 8, 2026 23:25
@stephanos stephanos changed the title Strongly consistent Nexus endpoints via dynamic config Strongly consistent Nexus endpoints lookup via dynamic config May 8, 2026
@stephanos stephanos closed this May 13, 2026
@stephanos stephanos reopened this May 15, 2026
@@ -163,6 +174,14 @@ func (r *EndpointRegistryImpl) GetByID(ctx context.Context, id string) (*persist
return nil, err
}

if r.config.refreshOnRead() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Even though GetByID falls back to query matching already on a cache miss, it could still provide a stale answer if the endpoint was changed/deleted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

True

@stephanos
stephanos force-pushed the stephanos/sano-flaky-endpoint-2 branch 2 times, most recently from 41d0029 to 34d8386 Compare May 15, 2026 18:32
@stephanos
stephanos force-pushed the stephanos/sano-flaky-endpoint-2 branch from 34d8386 to 76e0b29 Compare May 15, 2026 18:38
Comment thread tests/nexus_test_base.go
}
return true
}, 10*time.Second, 100*time.Millisecond, "endpoint should become visible")
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

obsolete now

@stephanos
stephanos marked this pull request as ready for review May 15, 2026 21:10
@stephanos
stephanos requested review from a team as code owners May 15, 2026 21:10
@stephanos
stephanos requested review from bergundy and chrsmith May 15, 2026 21:10
@@ -163,6 +174,14 @@ func (r *EndpointRegistryImpl) GetByID(ctx context.Context, id string) (*persist
return nil, err
}

if r.config.refreshOnRead() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

True

@chrsmith chrsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some optional nitpicks. LGTM.

Comment thread common/dynamicconfig/constants.go Outdated
false,
`RefreshNexusEndpointsOnRead forces the Nexus endpoint registry to refresh from matching service on read.
This effectively bypasses the cache so that endpoint writes are visible to readers immediately, instead of after the
next background long-poll refresh. This should not be turned on in production.`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Someone might read this and think "why not?", so maybe add a pithy explanation? e.g. "This should not be turned on in production, as it would introduce scalability/reliability problems." What do you think?

Comment thread common/nexus/endpoint_registry.go Outdated
// This is useful for test and single-node deployments that need endpoint writes
// to be visible to GetByName immediately, without waiting for background long poll.
if err := r.loadEndpoints(ctx); err != nil {
return nil, err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: It would be really confusing to see an error related to loading endpoints when calling GetByName. Perhaps we should use fmt.Errorf("refreshing endpoints: %w", err) here and below?

stephanos added a commit to stephanos/cli that referenced this pull request May 15, 2026
Matches the upstream rename in temporalio/temporal#10208 to better
mirror the existing forceSearchAttributesCacheRefreshOnRead naming.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stephanos
stephanos merged commit 659013e into main May 15, 2026
48 checks passed
@stephanos
stephanos deleted the stephanos/sano-flaky-endpoint-2 branch May 15, 2026 22:20
stephanos added a commit to temporalio/cli that referenced this pull request May 15, 2026
<!--- Note to EXTERNAL Contributors -->
<!-- Thanks for opening a PR! 
If it is a significant code change, please **make sure there is an open
issue** for this.
We work best with you when we have accepted the idea first before you
code. -->

<!--- For ALL Contributors 👇 -->

## What was changed
<!-- Describe what has changed in this PR -->

Mirrors the existing `forceSearchAttributesCacheRefreshOnRead` default:
makes Nexus endpoint writes immediately visible to readers instead of
after the next background long-poll refresh.

It was added here temporalio/temporal#10208

## Why

Better development experience.
stephanos added a commit that referenced this pull request May 20, 2026
## What changed?

Removed retries in test when Nexus endpoint wasn't found.

Follow-up to #10208

## Why?

Nexus lookups are now strongly consistent.
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.

5 participants