Skip to content
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

fix: only update wrappers_fdw_stats table in a read-write transaction #188

Merged
merged 2 commits into from
Nov 2, 2023

Conversation

imor
Copy link
Contributor

@imor imor commented Nov 2, 2023

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

If a query on a foreign table was done in a read-only transaction, it failed with this error:

ERROR:  cannot execute INSERT in a read-only transaction
CONTEXT:  SQL statement "insert into public.wrappers_fdw_stats as s (fdw_name, create_times) values($1, $2)
         on conflict(fdw_name)
         do update set
            create_times = coalesce(s.create_times, 0) + excluded.create_times,
            updated_at = timezone('utc'::text, now())"

What is the new behavior?

This error occurred because wrappers updated wrappers_fdw_stats table for each query on a foreign table. wrappers will now update the wrappers_fdw_stats table only if the transaction is read-write.

Additional context

N/A

@burmecia burmecia self-requested a review November 2, 2023 08:53
wrappers/src/stats.rs Show resolved Hide resolved
wrappers/src/stats.rs Outdated Show resolved Hide resolved
wrappers/src/stats.rs Outdated Show resolved Hide resolved
@imor imor changed the title only update wrappers_fdw_stats table in a read-write transaction fix: only update wrappers_fdw_stats table in a read-write transaction Nov 2, 2023
@burmecia burmecia merged commit be37e1e into main Nov 2, 2023
2 checks passed
@burmecia burmecia deleted the fix-read-only-txn branch November 2, 2023 09:25
@StanGirard
Copy link

@imor issue still occurs on hosted version with latest version of stripe with a fresh new project.

@imor
Copy link
Contributor Author

imor commented Nov 21, 2023

@StanGirard we haven't yet rolled out an image which includes the fixed version of wrappers (hope to do so in a couple of days). If it's urgent for you we can bump wrappers version for your project if you can raise a support ticket.

kamyshdm added a commit to dymium-io/supabase-wrappers that referenced this pull request Jun 17, 2024
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.

3 participants