Skip to content
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

Reduce intra cluster conflicts #5371

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

rnewson
Copy link
Member

@rnewson rnewson commented Dec 29, 2024

Overview

CouchDB issues all write requests in parallel without coordination, applying a quorum on the results of those independent actions. When updating a document concurrently this can lead to the introduction of a stored conflict if two different writes reach separate nodes first. This is undesirable.

This patch changes fabric_doc_update in the following ways;

  1. Workers are no longer started immediately, but are given a unique reference each.
  2. For each range in the write request, one node is chosen to "lead" the write decision (calculated as the lowest live node that hosts the shard range)
  3. "Leader" workers are started.
  4. Any doc update that receives "conflict" from a Leader is added to the reply dict W times and the doc updates are removed from the other (unstarted) workers. If that leaves the worker with nothing to do, it is removed entirely.

Testing recommendations

There is some existing coverage in the module itself but more testing is needed before this can be merged.

Related Issues or Pull Requests

Checklist

  • Code is written and works correctly
  • Changes are covered by tests
  • Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • Documentation changes were made in the src/docs folder
  • Documentation changes were backported (separated PR) to affected branches

@rnewson rnewson force-pushed the reduce-intra-cluster-conflicts branch 2 times, most recently from b727716 to 04000f7 Compare December 29, 2024 20:56
@rnewson
Copy link
Member Author

rnewson commented Jan 1, 2025

noting need for a liveness check at the start (so the 'leader' is always a live node as of the invocation) and also to consider maintenance mode (receipt of that message from a 'leader' specifically)

This should prevent spurious intra-cluster conflicts most of the
time. It is not true consistency, however. spurious conflicts are
still possible whenever the nodes in the cluster disagree on the
current live set of other nodes.
@rnewson rnewson force-pushed the reduce-intra-cluster-conflicts branch from 038b996 to 507b4c6 Compare January 2, 2025 19:52
ensure we start followers if leader node is down (rexi_DOWN) or
is in maintenance mode (rexi_EXIT).
@rnewson rnewson force-pushed the reduce-intra-cluster-conflicts branch from 507b4c6 to 577dc25 Compare January 6, 2025 10:34
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.

1 participant