Skip to content

[raft/scd] Derive implicit subscription ID deterministically - #1656

Merged
mickmis merged 1 commit into
interuss:masterfrom
Orbitalize:scd_deterministic_implicit_sub
Sep 2, 2026
Merged

[raft/scd] Derive implicit subscription ID deterministically#1656
mickmis merged 1 commit into
interuss:masterfrom
Orbitalize:scd_deterministic_implicit_sub

Conversation

@MariemBaccari

@MariemBaccari MariemBaccari commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Chained PR: #1627 -> #1642 -> #1643 -> #1644 -> #1645 -> #1646 -> #1649 -> #1650 -> #1651 -> #1653 -> #1654 -> #1656 -> #1657 -> #1655 -> #1666 -> #1667 -> #1668 -> #1669

upsertOperationalIntentReference's transaction creates a new random UUID when an implicit subscription is requested. However, this wouldn't execute deterministically across Raft nodes and entry replays.
There are two directions to solve this:

  • Pre-computing the UUID at the handler level, adding a parameters map field to the Proposal struct where each operation can pass its parameters and then passing the parameters in the context as we do for the timestamp and locality to propagate them to business logic. However, this solution is not very elegant and would actually only be used once by this case.
  • The solution that this PR goes with: Deterministically generating the subscription ID using the query timestamp and the opintent ID.

@MariemBaccari
MariemBaccari force-pushed the scd_deterministic_implicit_sub branch 3 times, most recently from 4db755d to 5ff0dfc Compare August 20, 2026 14:05
@MariemBaccari
MariemBaccari marked this pull request as ready for review August 20, 2026 14:15
@MariemBaccari
MariemBaccari force-pushed the scd_deterministic_implicit_sub branch 2 times, most recently from 475f91b to 7b88375 Compare August 20, 2026 15:30
@barroco barroco added the dss-raft Relating to the application-layer consensus implemenation based on raft label Aug 20, 2026
@MariemBaccari
MariemBaccari marked this pull request as draft August 21, 2026 06:31
@MariemBaccari
MariemBaccari force-pushed the scd_deterministic_implicit_sub branch from 7b88375 to 1e57680 Compare August 21, 2026 06:34
@MariemBaccari
MariemBaccari marked this pull request as ready for review August 21, 2026 06:42
@MariemBaccari
MariemBaccari marked this pull request as draft August 21, 2026 08:14
@MariemBaccari
MariemBaccari marked this pull request as ready for review August 21, 2026 08:24
@MariemBaccari
MariemBaccari force-pushed the scd_deterministic_implicit_sub branch from 1e57680 to 293b561 Compare August 28, 2026 10:10

@mickmis mickmis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(293b561)

  • this UUID is presenting itself as an UUIDv4 but it is actually not: see RFC, this should be random
  • I think with the deterministic intent, what should be implemented here would be a v5 (or a v7 with a stretch)
  • the OpenAPI does specifically mention the UUID should be a v4 (although I'm not sure how hard of a requirement that is as long as it is a UUID - but that would require to be discussed in the InterUSS weekly)
  • I don't think the actualization of the 'now' at each retry is a good idea (in general we should be careful with stuff we put in the context)

The business logic does require us to generate (pseudo-)random data, but we need determinism across nodes. To solve this, have you considered the alternative of (generically) propagating a seed value through the Raft messages? That way all nodes will be able to deterministically generate (pseudo-)random values. I suspect we may encounter this problem again actually?

@MariemBaccari
MariemBaccari force-pushed the scd_deterministic_implicit_sub branch 6 times, most recently from 3be0e79 to 26fd216 Compare September 2, 2026 11:31
@MariemBaccari

Copy link
Copy Markdown
Contributor Author

@mickmis Thanks for the feedback, I really like the idea of propagating a seed value through the proposal. I just implemented that in a similar way as the timestamp propagation.

@mickmis mickmis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo minor comment

Comment thread pkg/random/random.go Outdated
Comment on lines +47 to +48
func Generator(ctx context.Context, label string) (*mrand.Rand, error) {
seed := MustFromContext(ctx)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this may panic without the function following the convention MustX, either:

  • rename to MustGenerator (meh)
  • change signature to pass the seed and not the context
  • get seed from context and return error if not present instead of panicking (preferred IMO)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the second option allows us to remain consistent with timestamp and locality. The panic in MustFromContext makes sense in the same way since the seed has to be generated for every single request. I just pushed that.

@MariemBaccari
MariemBaccari force-pushed the scd_deterministic_implicit_sub branch from 26fd216 to 7e89936 Compare September 2, 2026 12:39
@MariemBaccari
MariemBaccari force-pushed the scd_deterministic_implicit_sub branch from 7e89936 to f4c0eee Compare September 2, 2026 12:42
@mickmis
mickmis merged commit 0f66770 into interuss:master Sep 2, 2026
18 checks passed
@mickmis
mickmis deleted the scd_deterministic_implicit_sub branch September 2, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dss-raft Relating to the application-layer consensus implemenation based on raft

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants