Skip to content

Conversation

@honchow
Copy link

@honchow honchow commented Oct 10, 2025

Add settings.autoPromoteHidden boolean configuration (default: false):

When enabled: Hidden nodes automatically appear in the hosts array of hello/isMaster responses when all non-hidden secondaries are down
When disabled: Preserves current behavior (hidden nodes never exposed)
Auto-recovery: Hidden nodes automatically demoted when non-hidden secondaries recover

@honchow honchow changed the title [feature] mongod: add auto promote hidden [feature] mongod: auto promote hidden Oct 10, 2025
@honchow honchow changed the title [feature] mongod: auto promote hidden SERVER-112278 Add settings.autoPromoteHidden boolean configuration Oct 10, 2025
@honchow honchow marked this pull request as ready for review October 10, 2025 09:25
@y123456yz
Copy link
Contributor

y123456yz commented Oct 10, 2025

Currently, the MongoDB service architectures provided by various cloud service providers are almost all 1-master-1-slave and 1-hidden. The hidden nodes are mainly used for data backup. Over the years of our large-scale cluster operation data, we have discovered a serious problem: many users, in order to take advantage of the slave nodes, will configure read-write separation, where the read preference is set to secondary‌.
Since there is only one slave node providing read services, all business reads will fail in the following scenarios because there is no slave node:

  1. The server where the node is located has failed
  2. From node crash or kernel bug
    Currently, the MongoDB kernel can unhidden nodes to provide services through rs.conf. However, it usually only unhides nodes when users detect business errors or when DBAs conduct inspections and find that slave nodes are unavailable. By this time it's too late. Usually, it takes several minutes or hours to discover the problem.
    This PR is designed to address this issue. When all the slave nodes are unavailable, we automatically elevate the hidden node to the second node in db.ismaster() command. In this way, the business can read this hidden node.

@y123456yz
Copy link
Contributor

@kelly-cs
Copy link
Contributor

Thanks for making this pull request! We just need a couple of things from you to start our consideration of the PR. Can you please sign our Contributor's Agreement referencing the account that made this PR?

This seems like a neat change to have for that use case.

@honchow
Copy link
Author

honchow commented Oct 11, 2025

Thanks for making this pull request! We just need a couple of things from you to start our consideration of the PR. Can you please sign our Contributor's Agreement referencing the account that made this PR?

This seems like a neat change to have for that use case.

Thanks — I’ve signed the Contributor’s Agreement referencing the GitHub account that opened this PR.

A couple of notes about the PR:
I still need to add integration tests to cover the new behavior.
I need to consider whether there may be compatibility issues across different releases versions.

I’ll prepare those changes and push an update shortly.

@honchow honchow force-pushed the dev_honchow_promote_hidden branch from 42d2812 to bab02fc Compare October 11, 2025 09:36
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.

3 participants