feat(engine): embed cluster node id into worker-scoped ids - #2421
Merged
Conversation
EngineWorker mints initialId, promiseId, traceId, budgetId, authorizedId, and its own affinityId counter from one shared `initial`/`mask` pair that previously encoded only this node's local worker index (top byte, bits 56-63). Every such id was therefore unique only within one engine instance -- a traceId minted on one cluster node's worker 2 could collide numerically with one minted on a different node's worker 2, defeating cross-node trace/log correlation for any router that fans work out across physical nodes (see RouterContext). Folds EngineConfiguration's own node.id byte into the same `initial` value, immediately below the existing worker-index byte (bits 48-55, previously always zero) -- forming one contiguous 16-bit (node, worker) pair. Every id derived from `initial`/`mask` becomes cluster-wide unique as a result, with no change to the existing per-worker counter width or to indexOfId's local dispatch semantics (guard verifier/identifier/attributor routing, budget ownership resolution). Adds nodeOfId alongside the existing indexOfId for symmetry. node.id defaults to 0, so this is a no-op for every single-node deployment.
…sector Follow-up to the previous commit: zilla.lua showed trace_id as one opaque 64-bit hex value, with no visibility into the (node, worker) pair now embedded in it. Adds trace_id.node and trace_id.worker as child fields under a new Trace ID subtree, extracted from the same byte range as plain single-byte slices (bytes 6 and 7 of the little-endian trace_id field) rather than a 64-bit bitmask, avoiding any precision concerns. Also drops an explanatory comment on NODE_SHIFT_SIZE from the prior commit that wasn't earning its place.
The Trace ID field in zilla dump output is now a subtree with nested Node and Worker fields; regenerate the 25 golden fixtures used by the tshark-based command-dump integration tests to match.
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
EngineWorkermintsinitialId,promiseId,traceId,budgetId,authorizedId, and its ownaffinityIdcounter from one sharedinitial/maskpair that previously encoded only this node's local worker index (top byte, bits 56-63). Every such id was therefore unique only within one engine instance — atraceIdminted on one node's worker 2 can numerically collide with one minted on a different node's worker 2.That matters once a
RouterContextimplementation fans work out across physical nodes (the SPI already supports this —RouteableContext#attachComposite/supplyStore,RouterContext#resolveRoutedId) rather than only across local workers: any consumer oftraceId/budgetId/etc. for cross-node trace or log correlation (zilla dumpoutput included, once a stream has been forwarded to a different node and back) can't disambiguate two ids that happen to share the same local worker index on different nodes.This folds
EngineConfiguration's ownnode.idbyte into the sameinitialvalue, immediately below the existing worker-index byte (bits 48-55, previously always zero) — forming one contiguous 16-bit (node, worker) pair. Every id derived frominitial/maskbecomes cluster-wide unique as a result, with:RESERVED_SIZE)indexOfId's existing local-dispatch semantics (guard verifier/identifier/attributor routing,BudgetId#ownerIndexresolution) — both still read only the unmoved worker-index bytenodeOfIdalongside the existingindexOfId, for symmetrynode.iddefaults to0, so this is a no-op for every single-node deployment — verified via the fullruntime/engineunit + integration test suite (438 tests, 0 failures) andcheckstyle:check(0 violations), both green before and after this change.Test plan
./mvnw checkstyle:check -pl runtime/engine— 0 violations./mvnw clean install -pl runtime/engine -am -DskipTests=false— full unit + IT suite green (228 unit tests, 210 integration tests, 0 failures/errors)Generated by Claude Code