Improve API for the site metadata - #46
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the site metadata API by separating cluster-replicated metadata from site-private metadata, and updates the codebase/tests to use the new API surface. It also refactors some cluster/site identity helpers and moves the restart-counter API into classy_node.
Changes:
- Introduces
classy_site_metadatasplit API (c_*for cluster metadata,s_*for site-private metadata) including atomic batch operations. - Adds
classy:the_site_err/0andclassy:the_cluster_err/0formaybe-friendly error tuples and updates some callers. - Moves
n_restarts/0and restart counter incrementing fromclassy_livenessintoclassy_node, updating dependent modules/tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/classy_SUITE.erl | Updates tests to use new classy_site_metadata API and extends coverage for atomic operations and leave semantics. |
| src/classy.erl | Updates docs/exports, removes old site-prop wrappers, and adds *_err/0 helpers used in maybe flows. |
| src/classy_uid.erl | Switches restart counter source from classy_liveness to classy_node. |
| src/classy_site_metadata.erl | Implements the new c_*/s_* metadata APIs, namespacing, persistence, and propagation. |
| src/classy_node.erl | Introduces per-node persistent table keying, adds restart counter API, and initializes/terminates site metadata table. |
| src/classy_liveness.erl | Removes exported restart counter API and delegates restart counting to classy_node. |
| src/classy_internal.hrl | Removes shared ?globals/?n_restarts macros (now owned by specific modules). |
| src/classy_hook.erl | Removes the on_leave hook that previously triggered metadata cleanup. |
Suppressed comments (1)
test/classy_SUITE.erl:936
- These comments still refer to "globals" even though the testcase now exercises site-private metadata (
s_*APIs). Updating them will make the test intent clearer.
%% First, all globals are empty:
?assertEqual(#{}, ?ON(S1, classy_site_metadata:s_get_all())),
%% Set a global:
?assertMatch(ok, ?ON(S1, classy_site_metadata:s_set(foo, foo))),
?assertMatch(ok, ?ON(S2, classy_site_metadata:s_set(bar, bar))),
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b63506f to
6f36949
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
src/classy_site_metadata.erl:92
- Spelling typo in the
s_set/2docstring: "Persistentley" should be "Persistently".
-doc """
Persistentley set a site property.
These properties survive all cluster changes,
they don't get cleaned automatically.
6f36949 to
39a4d4d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/classy_site_metadata.erl:89
- Typo in moduledoc: "Persistentley" should be "Persistently".
-doc """
Persistentley set a site property.
src/classy_site_metadata.erl:159
- In
c_atomically/2,propagate(Cluster)is called but its result is ignored, so the function can return{ok, Effects}even when propagation toclassy_membershipfails. This can leave peers with stale metadata while callers believe the operation fully succeeded.
{ok, Effects} ?= classy_table:atomically(?tab, Ops),
propagate(Cluster),
{ok, Effects}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/classy_site_metadata.erl:88
- Typo in docstring: “Persistentley” should be “Persistently” (also matches spelling used elsewhere in docs).
Persistentley set a site property.
src/classy_vote.erl:511
- Typo in comment: “relevent” should be “relevant”.
%% aren't relevent for tests:
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Suppressed comments (3)
src/classy_site_metadata.erl:269
propagate/1currently returns the result ofclassy_membership:set_info/3(now{ok, Clock}), which meansc_set/3andc_delete/2will return{ok, Clock}despite their specs statingok | {error, _}. This is an API behavior change and is likely to break callers matching onok.
propagate(Cluster) ->
maybe
{ok, Site} ?= classy:the_site_err(),
classy_membership:set_info(
Cluster,
src/classy_site_metadata.erl:159
c_atomically/2callspropagate/1but does not check its result. If propagation fails, the function will still return{ok, Effects}, leaving local state updated but gossip/membership info stale.
This issue also appears on line 265 of the same file.
{ok, Effects} ?= classy_table:atomically(?tab, Ops),
propagate(Cluster),
{ok, Effects}
src/test/classy_test_fuzzer.erl:552
- The numeric literal
20_0is equivalent to200, but it’s an unusual separator placement and easy to misread as a typo. Using200would be clearer and consistent with the previous value.
wait_clusters_converge(S) ->
?retry(100, 20_0,
maps:foreach(
fd98ff3 to
c14626c
Compare
Uh oh!
There was an error while loading. Please reload this page.