fix: nacos service discovery request lacks retries after failure#12734
Merged
Conversation
Baoyuantop
marked this pull request as ready for review
November 7, 2025 00:55
nic-6443
reviewed
Nov 24, 2025
AlinsRan
reviewed
Nov 25, 2025
| local function get_base_uri_by_index(index) | ||
| local host = local_conf.discovery.nacos.host | ||
| if type(host) ~= 'table' then | ||
| return nil |
Contributor
There was a problem hiding this comment.
We should return error information.
Contributor
Author
There was a problem hiding this comment.
I opted out of that check; it felt a bit unnecessary.
AlinsRan
reviewed
Nov 25, 2025
| local data, req_err = get_url(base_uri, query_path) | ||
| if req_err then | ||
| last_err = req_err | ||
| log.warn('get_url:', query_path, ' err:', req_err, ', host:', base_uri) |
Contributor
There was a problem hiding this comment.
The warn log message is not specific enough. It looks like a debug log.
Contributor
Author
There was a problem hiding this comment.
I improved the log information.
AlinsRan
reviewed
Nov 25, 2025
| end | ||
| end | ||
|
|
||
| log.error('failed to fetch nacos registry from all hosts: ', last_err) |
Contributor
There was a problem hiding this comment.
Every err will be printed, doesn't it seem necessary to print it again at the end?
Contributor
Author
There was a problem hiding this comment.
I removed last_err and now print each error in the loop, and if all errors occur, I print an error log at the end.
nic-6443
approved these changes
Dec 8, 2025
AlinsRan
approved these changes
Dec 9, 2025
membphis
approved these changes
Dec 9, 2025
5 tasks
wistefan
pushed a commit
to wistefan/apisix
that referenced
this pull request
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
After confirmation, the problem described in the original issue also exists in nacos service discovery. Currently, if multiple nacos nodes are configured, a request will randomly select one; if that node fails, the request can only be made again during the next synchronization.
This PR optimizes this behavior so that when a request from one node fails, it will resend the request to other nodes.
Which issue(s) this PR fixes:
Fixes #12610
Checklist
Fixes #8782