-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Populate zone attribute from COUCHDB_ZONE environment variable #5588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
2f77912 to
31d381f
Compare
rnewson
reviewed
Jul 7, 2025
src/couch/src/couch_util.erl
Outdated
| Value :: any(), | ||
| TupleList2 :: [Tuple]. | ||
| set_value(Key, TupleList1, Value) -> | ||
| TupleList2 = [{Key, Value} | TupleList1], |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nickva
reviewed
Jul 7, 2025
nickva
reviewed
Jul 7, 2025
couch_util:set_value/3 previously only worked when replacing a value associated with an existing key. This commit changes the semantics to be "set or update". I've also added a typespec for completeness.
940e5f1 to
9f87d3a
Compare
nickva
approved these changes
Jul 7, 2025
Contributor
nickva
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Thanks for also updating the docs
big-r81
reviewed
Jul 7, 2025
big-r81
reviewed
Jul 7, 2025
This adds a feature to populate the zone field in the `nodes` database by setting the `COUCHDB_ZONE` environment variable. The zone is used in combination with [placement](https://docs.couchdb.org/en/stable/cluster/databases.html#placing-a-database-on-specific-nodes) rules to specify that database shard replicas must exist across specific nodes - most commonly used to specify that a replica should exist in multiple availability zones in a region. Setting the zone was previously an awkward piece of cluster setup orchestration because it required editing the node document in the local "nodes" database before creating any system databases. This instead sets the zone when initially creating the node document on startup, which should then get replicated to other peers in the cluster. One nuance is that multiple nodes in the cluster might create the same first revision of the node document due to the seedlist feature. To prevent conflicts when the nodes database is replicated internally, the zone is set using an additional update to the document associated with the current node only.
9f87d3a to
88e23b5
Compare
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.
Overview
This adds a feature to populate the zone field in the
nodesdatabase by setting theCOUCHDB_ZONEenvironment variable. Setting the zone for a node was previously an awkward piece of cluster setup orchestration because it required editing the a document on each of the local "nodes" after CouchDB has started but before creating any other system databases.This implementation reads the
COUCHDB_ZONEenvironment variable when mem3 starts and, if present, updates the local node document with that zone string.One nuance is that multiple nodes in the cluster might create the same first revision of a node document due to the seedlist feature, which pre-emptively adds the seeds to the nodes database. To prevent conflicts when the nodes database is replicated between peers, the zone is set using an additional update to the node document for the local node only.
Other things to note:
COUCHDB_ZONEto change in the lifetime of a node, but the code does allow this.COUCHDB_ZONEis not set, no modifications to the node document are made.Testing recommendations
Eunit tests are added to verify the node document is as expected. You can also test using:
Related Issues or Pull Requests
Checklist
rel/overlay/etc/default.inisrc/docsfolder