Skip to content

Improve document grouping in fabric_doc_update#6032

Open
nickva wants to merge 1 commit into
mainfrom
fix-groups-by-range-in-fabric-doc-update
Open

Improve document grouping in fabric_doc_update#6032
nickva wants to merge 1 commit into
mainfrom
fix-groups-by-range-in-fabric-doc-update

Conversation

@nickva

@nickva nickva commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

The idea of doc/shard grouping and rotation was that different databases would start their workers on different copies, spread those uniformly and consistently by {Range, DbName}.

However, the order of entries were actually dependent on dict:to_list/1 internals. So, if dict was changed to return sorted items, like for instance maps do, we'd end up suddently breaking the supposedly randomized spread (I found this out by actually trying to use a map there instead of a dict).

To fix this, make the rotation explicit. Group the entries first, then sort each group, and then rotate by {Range, DbName}.

While at it make it so we don't have to duplicate the main rotate function in tests and use the actual function we intend to test.

@nickva nickva force-pushed the fix-groups-by-range-in-fabric-doc-update branch from bb78d62 to 8b33ae2 Compare June 10, 2026 22:59
@nickva nickva requested a review from rnewson June 10, 2026 22:59
@nickva nickva force-pushed the fix-groups-by-range-in-fabric-doc-update branch from 8b33ae2 to 1a1a408 Compare June 11, 2026 17:51
@nickva nickva removed the request for review from rnewson June 11, 2026 17:52
@nickva nickva force-pushed the fix-groups-by-range-in-fabric-doc-update branch from 1a1a408 to 14039a4 Compare June 12, 2026 14:42
@nickva nickva requested a review from rnewson June 12, 2026 14:42
@nickva nickva force-pushed the fix-groups-by-range-in-fabric-doc-update branch from 14039a4 to 69342d9 Compare June 12, 2026 15:32
@nickva nickva removed the request for review from rnewson June 13, 2026 00:28
The idea of doc/shard grouping and rotation was that different databases would
start their workers on different copies, spread those uniformly and
consistently by database and range.

However, the order of entries were actually dependent on `dict:to_list/1`
internals. So, if `dict` was changed to return sorted items, like for instance
maps do, we'd end up suddenly breaking the supposedly randomized spread (I
found this out by actually trying to use a map there instead of a dict).

To fix this, make the ordering explicit. Group the entries first, then order
each range's group by the unified `mem3:owners/3` membership order, so the
first copy of each range lands on the owner node, consistent with "Unify
membership hashes", and the result no longer depends on dict internals at all.

While at it make it so we don't have to duplicate the main rotate function in
tests and use the actual function we intend to test.
@nickva nickva force-pushed the fix-groups-by-range-in-fabric-doc-update branch from 69342d9 to c36d65f Compare June 13, 2026 00:28
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