Skip to content

Conversation

@alco
Copy link
Member

@alco alco commented Oct 13, 2025

Closes #3260.

This PR is missing the query for WAL size but the surrounding logic is ready for review.

I'll implement the query in a follow-up PR because I want to build a basic synchronous interface on top of Postgrex.SimpleConnection.

@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 16.66667% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.05%. Comparing base (60c8d10) to head (bd2bd19).

Files with missing lines Patch % Lines
.../sync-service/lib/electric/connection/restarter.ex 0.00% 20 Missing ⚠️
...es/sync-service/lib/electric/connection/manager.ex 0.00% 9 Missing ⚠️
packages/sync-service/lib/electric/config.ex 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3274      +/-   ##
==========================================
- Coverage   69.83%   67.05%   -2.79%     
==========================================
  Files         181      172       -9     
  Lines        9777     8872     -905     
  Branches      336      106     -230     
==========================================
- Hits         6828     5949     -879     
+ Misses       2947     2922      -25     
+ Partials        2        1       -1     
Flag Coverage Δ
elixir 66.77% <16.66%> (-0.22%) ⬇️
elixir-client 73.94% <ø> (ø)
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/typescript-client ?
packages/y-electric 55.12% <ø> (ø)
postgres-140000 65.81% <16.66%> (-0.18%) ⬇️
postgres-150000 65.85% <16.66%> (-0.22%) ⬇️
postgres-170000 65.78% <16.66%> (-0.15%) ⬇️
postgres-180000 ?
sync-service 66.06% <16.66%> (-0.24%) ⬇️
typescript 72.39% <ø> (-14.86%) ⬇️
unit-tests 67.05% <16.66%> (-2.79%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alco alco force-pushed the alco/wal-size-check branch from 35d985e to ca3a175 Compare October 13, 2025 23:01
@alco alco changed the title Add a configuration option to set the WAL check period in scaled down mode Add two new configuration options for periodic retained WAL size check in scaled down mode Oct 13, 2025
@alco alco changed the base branch from main to alco/scaled-down-stack-event October 13, 2025 23:02
@alco alco force-pushed the alco/wal-size-check branch 2 times, most recently from 4730f9c to fd65b33 Compare October 13, 2025 23:19
@alco alco marked this pull request as ready for review October 13, 2025 23:26
Copy link
Contributor

@msfstef msfstef left a comment

Choose a reason for hiding this comment

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

Looks good but I assume this does not work since there's no querying of the wal size (and no tests which I assume is for the above reason?)


defp query_retained_wal_size(_state) do
# FIXME: placeholder
0
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this doesn't work until this is fixed

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I'll add the query and extend the integration test in a follow-up PR to be merged into this one.

else
try do
with {:ok, validated_opts} <- ConnectionResolver.validate(state.stack_id, conn_opts) do
Electric.StackConfig.put(state.stack_id, config_key, validated_opts)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love the dynamic configuration on this in the sense that the only reason to have it is for something to use it outside of the connection manager, in which case it doesn't really know when it is ready?

Also if the connection manager crashes, which could be because of a change in the connection configurations, would we not perhaps want to revalidated the connection options passed to us?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a great point. The original implementation of connection option validation was modelled as a uni-directional flow: i.e. once we fall back from SSL to noSSL or from SSL to unencrypted, there was no going back. I've always thought of the revalidation when connection manager restarts as a redundant step. But you're proposing that it is, in fact, an opportunity to redo the validation?

Given that Electric.StackConfig lives under the StackSupervisor, any change in the stack configuration will erase its cached connection options and so there's no problem with having stale validated options.

From my perspective, doing validation once is the goal. We could implement it by running connection resolver for replication and pool connections upfront, before proceeding to initialize connection manager for the first time. Conceptually, this would not be as controversial, I think, but it would be at the cost of increased latency on the first connection setup.

@alco alco force-pushed the alco/scaled-down-stack-event branch from 92a696c to 38a1a84 Compare October 22, 2025 12:39
Base automatically changed from alco/scaled-down-stack-event to main October 22, 2025 12:54
@alco alco force-pushed the alco/wal-size-check branch from fd65b33 to bd2bd19 Compare November 3, 2025 10:35
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.

Add a configuration option to set the WAL check period in scaled down mode

3 participants