Skip to content

[raft/memstore] Add scd memstore - #1542

Merged
mickmis merged 1 commit into
interuss:masterfrom
Orbitalize:memstore_scd
Aug 5, 2026
Merged

[raft/memstore] Add scd memstore#1542
mickmis merged 1 commit into
interuss:masterfrom
Orbitalize:memstore_scd

Conversation

@the-glu

@the-glu the-glu commented Jun 17, 2026

Copy link
Copy Markdown
Member

This PR is part of a new chain, implementing memstore.

#1525 (Generic raftstore) -> #1527 (Base memstore) -> #1529 (Aux memstore) -> #1530 (Snapshots) -> #1534 (Rid memstore) -> #1535 (Correct use of now) -> #1539 (Checkpoint) -> #1542 (Scd memstore) -> #1528 (First PR with raft using memstore)


It adds SCD memstore.

The PR is quite big, as it's the whole SCD memstore. However, individual files can be checked separately.

There were no existing tests compared to RID, except for expired operational intents / subscriptions. Those two have been copied, and the rest is new.

Comment thread pkg/scd/store/memstore/availability.go Outdated
@barroco barroco added the dss-raft Relating to the application-layer consensus implemenation based on raft label Jun 17, 2026
@the-glu
the-glu force-pushed the memstore_scd branch 2 times, most recently from 04a7568 to ee03a27 Compare June 18, 2026 08:47
@the-glu
the-glu force-pushed the memstore_scd branch 2 times, most recently from 7ea03cd to e55c786 Compare June 29, 2026 07:05
@the-glu
the-glu force-pushed the memstore_scd branch 3 times, most recently from 9a30121 to 00ce64a Compare July 1, 2026 09:24
@the-glu
the-glu force-pushed the memstore_scd branch 2 times, most recently from b703298 to 8ad6994 Compare July 31, 2026 07:30
Comment thread pkg/scd/store/memstore/store.go Outdated
return true
}

func clonePtr[T any](v *T) *T {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

question: we should probably move common function to a utils package right? Or should every memstore kept it owns helpers ?

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.

Agreed, it could simply be in pkg/memstore

@the-glu

the-glu commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

@mickmis That one should be ready for a review

@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 comments

require.NoError(t, err)
require.Equal(t, manager, got.Uss)
require.Equal(t, scdmodels.UssAvailabilityStateNormal, got.Availability)
require.NotEmpty(t, got.Version)

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.

Check actual value? Hardcoding expectation here is fine IMO

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed, but it's a bit weak (changing computation mean changing it, witch is not great)

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.

I think it's a good thing actually? IMO it is very acceptable, desirable even, to have to change the value here if we change how we compute the OVN, because it is part of the behavior of the function we are unit testing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Depend on what you want to test. I'm more to test "something is returned" and "it's the same thing that is returned later", not "the value is generated the way I expected because I froze time/random", that not really IMO the goal of the test. The requirement is to return a value with some characteristics, not a value we choose and enforce because of it's characteristics.

Should the version be slightly different and the function implementing change, changing all tests to conform to the new value (and probably by taking the test message to get the new one) don't add much.

(But IMO/nits ^^')

Comment thread pkg/scd/store/memstore/availability_test.go
Comment thread pkg/scd/store/memstore/store.go Outdated
return true
}

func clonePtr[T any](v *T) *T {

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.

Agreed, it could simply be in pkg/memstore

func (r *repo) UpsertConstraint(_ context.Context, constraint *scdmodels.Constraint) (*scdmodels.Constraint, error) {
return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "UpsertConstraint not implemented for memstore")
func (r *repo) UpsertConstraint(ctx context.Context, s *scdmodels.Constraint) (*scdmodels.Constraint, error) {
if _, err := dsssql.CellUnionToCellIdsWithValidation(s.Cells); err != nil {

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.

Just validate with geo.ValidateCell then?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a small helper on the loop + convert, is it worth it to change it back?

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.

nit: I'd factor away the loop in utils.go and use it here. But is it worth it? Meh up to you.

Comment thread pkg/scd/store/memstore/constraints_test.go Outdated
Comment thread pkg/scd/store/memstore/subscriptions.go
Comment thread pkg/scd/store/memstore/subscriptions.go
@the-glu
the-glu force-pushed the memstore_scd branch 2 times, most recently from 5a425af to e607151 Compare August 4, 2026 16:34
Comment thread pkg/scd/store/memstore/availability_test.go
require.NoError(t, err)
require.Equal(t, manager, got.Uss)
require.Equal(t, scdmodels.UssAvailabilityStateNormal, got.Availability)
require.NotEmpty(t, got.Version)

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.

I think it's a good thing actually? IMO it is very acceptable, desirable even, to have to change the value here if we change how we compute the OVN, because it is part of the behavior of the function we are unit testing.

func (r *repo) UpsertConstraint(_ context.Context, constraint *scdmodels.Constraint) (*scdmodels.Constraint, error) {
return nil, stacktrace.NewErrorWithCode(dsserr.NotImplemented, "UpsertConstraint not implemented for memstore")
func (r *repo) UpsertConstraint(ctx context.Context, s *scdmodels.Constraint) (*scdmodels.Constraint, error) {
if _, err := dsssql.CellUnionToCellIdsWithValidation(s.Cells); err != nil {

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.

nit: I'd factor away the loop in utils.go and use it here. But is it worth it? Meh up to you.

@mickmis
mickmis merged commit a7ee1f3 into interuss:master Aug 5, 2026
12 checks passed
@mickmis
mickmis deleted the memstore_scd branch August 5, 2026 12:25
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.

4 participants