supabase / wrappers

Postgres Foreign Data Wrapper development framework in Rust.
http://fdw.dev
Apache License 2.0
546 stars 53 forks source link

Updating to 0.1.16 from 0.1.14 broke my wrapper due to access issues to `wrappers.wrappers_fdw_stats` #131

Open pjmv opened 1 year ago

pjmv commented 1 year ago

Bug report

Describe the bug

I was using a wrapper on my Cloud Supabase install. I needed to upgrade to be able to use the Airtable wrapper. To do so, I paused the project and reinstalled, as per advice offered on Discord (https://discord.com/channels/839993398554656828/1006358244786196510/threads/1144271220414631956)

Since then queries on the foreign tables fail because of permission denied for table wrappers_fdw_stats, even with the postgres user in psql.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Pause/Resume your project on Supabase from a previous version
  2. `select * from stripe.customers limit 3;
  3. see the following error message
    ERROR:  permission denied for table wrappers_fdw_stats
    CONTEXT:  SQL statement "insert into wrappers.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())"

Expected behavior

My previously configured foreign tables to work as previously

System information

Irrelevant as the problem happens server-side at Supabase's

Additional context

I tried grant all on wrappers.wrappers_fdw_stats to postgres; but even that failed with the same error.

pjmv commented 1 year ago

I "solved" my problem by nuking everything with DROP EXTENSION wrappers CASCADE and reinstalling everything afterwards which was acceptable for me as the cascade stopped at a foreign table. However I don't know how that would work for more intricate situations where the dependency chain goes further.

burmecia commented 1 year ago

In which schema did you install wrappers extension? I suspect that might be caused by pause/restore didn't restore permission correctly. And how did you upgrade the extension, is it before pause/restore or after?

pjmv commented 1 year ago

I did install the wrappers extension WITH SCHEMA wrappers

I did not see a solution to upgrade without doing pause/restore, and the pause/restore solution was suggested to me by GaryAustin1 on the Supabase Discord. It seemed like the only solution to graduate to the latest release of the wrappers extension.

thompsonbear commented 1 year ago

I ran into this issue in the past on database upgrade and it was determined that the api key for the integration (stored in vault) was not properly decrypted post database upgrade. The vault secret for the integration needed to be removed and re-added to access the foreign data from the wrapper table.

pjmv commented 1 year ago

I ran into this issue in the past on database upgrade and it was determined that the api key for the integration (stored in vault) was not properly decrypted post database upgrade. The vault secret for the integration needed to be removed and re-added to access the foreign data from the wrapper table.

I am not sure how this is related because my issue was with the wrappers_fdw_stats which sits locally, not remotely ?

However it does suggest that the upgrade process should be handled a bit more gracefully...

NeoPrint3D commented 1 year ago

any updates I am currently trying to use the stripe wrapper but I am getting the same problem when trying to access data from the frontend

imor commented 1 year ago

If anyone's on the hosted version, could you please raise a support ticket. As @burmecia has pointed out, the pause/resume might have failed to restore permissions.

Pluriscient commented 5 months ago

Created a support request for this on the hosted version (just set up a fresh install of the stripe wrapper - twice - and this problem occurs when querying a view that uses the stripe information