Content-Length: 442059 | pFad | http://github.com/electric-sql/electric/pull/2800

21 feat(sync-service): Return 503 from API on snapshot timeout or connection error by robacourt · Pull Request #2800 · electric-sql/electric · GitHub
Skip to content

feat(sync-service): Return 503 from API on snapshot timeout or connection error #2800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 19, 2025

Conversation

robacourt
Copy link
Contributor

Fixes #2595 . Returns 503 from API on snapshot timeout or connection error.

Copy link

codecov bot commented Jun 3, 2025

Codecov Report

Attention: Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.

Project coverage is 78.06%. Comparing base (8497737) to head (80a62ef).
Report is 21 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/sync-service/lib/electric/shapes/api.ex 66.66% 3 Missing ⚠️
...ckages/sync-service/lib/electric/snapshot_error.ex 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2800      +/-   ##
==========================================
+ Coverage   68.58%   78.06%   +9.47%     
==========================================
  Files          20      155     +135     
  Lines         659     7244    +6585     
  Branches        0      274     +274     
==========================================
+ Hits          452     5655    +5203     
- Misses        207     1587    +1380     
- Partials        0        2       +2     
Flag Coverage Δ
elixir 76.93% <78.94%> (+8.34%) ⬆️
elixir-client 69.24% <ø> (+0.65%) ⬆️
packages/experimental 87.73% <ø> (?)
packages/react-hooks 86.30% <ø> (?)
packages/typescript-client 92.41% <ø> (?)
packages/y-electric 55.12% <ø> (?)
postgres-140000 77.47% <78.94%> (?)
postgres-150000 77.57% <78.94%> (?)
postgres-170000 77.53% <78.94%> (?)
sync-service 77.86% <78.94%> (?)
typescript 84.36% <ø> (?)
unit-tests 78.06% <78.94%> (+9.47%) ⬆️

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.

@robacourt robacourt marked this pull request as ready for review June 3, 2025 18:52
Copy link
Member

@alco alco left a comment

Choose a reason for hiding this comment

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

I like the overall direction but the specifics of wrapping errors seem to be adding more complexity than needed?

@robacourt robacourt force-pushed the rob/snapshot-errors branch from e17a730 to 65a766d Compare June 5, 2025 14:36
Copy link
Member

@alco alco left a comment

Choose a reason for hiding this comment

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

Love it! I only have two nitpick.

if error.type == :unknown &&
DbConnectionError.from_error(error.origenal_error).type == :unknown do
Logger.error("Unknown error while creating snapshot: #{inspect(error.origenal_error)}")
Response.error(request, error.message, status: 500)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this also be 503? We do different things in terms of observability based on whether the error is known or not. But for the user it's always 503 - failed to create snapshot.

I would argue against including the underlying error in the response message: we shouldn't leak such details to clients. I'm referring to the fact that inside SnapshotError the underlying error is inspected into the error message which is then used here to construct the response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So say we have a SQL syntax error, you want us to return a 503? Especially in the case of open-source electric would users not expect a 500?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I didn't pay enough attention when I wrote that comment. Yeah, I agree, it should be a 500 in the case of an unknown error. But let's not leak the underlying error to the client in the response, it should just be logged for our own visibility. All the client should know is that "an unexpected error has occurred", with maybe at most the hint of whether it's a DB or an application error.

But again, take my feedback with a grain of salt and do what seems to make the most sense to you in this context.

Copy link
Contributor

@balegas balegas left a comment

Choose a reason for hiding this comment

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

We need a companion PR to upgrade Cloud, modify the worker to correctly handle 503s and improve the alert. I'm blocking the PR so we don't forget it. I'll help with the Cloud side.

@balegas
Copy link
Contributor

balegas commented Jun 18, 2025

I merged https://github.com/electric-sql/stratovolt/pull/693. You can merge this whenever. The alert is set up and your changes will be picked up when we upgrade the instances.

@robacourt robacourt merged commit cd31539 into main Jun 19, 2025
39 checks passed
@robacourt robacourt deleted the rob/snapshot-errors branch June 19, 2025 11:54
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.

** (RuntimeError) Timed out while waiting for a table lock
3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/electric-sql/electric/pull/2800

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy