Обсуждение: Extension disappearing act

Поиск
Список
Период
Сортировка

Extension disappearing act

От
Dominique Devienne
Дата:
Hi. Little mystery we don't understand. v17.

Create new DB, owned by dedicated new ROLE.
Create extension (pgcrypto) in our case. Installed in public, owned by
DB owner role.
Create schemas and populate them inside the DB.
This also creates roles associated to those schemas.
One of the schema is owned by the DB owner (in case that matters).
Creates functions using pgcrypto, in some of those schemas.
Drop all schemas (and associated roles), thus pgcrypto-using functins are gone.
Of course, the DB owner role was not dropped. Can't in fact.
Somehow, the pgcrypto extension has disappeared, as side-effects of the drops.
We did a LIBPQ trace of the command to does all the drops,
and there's no explicit drop of the extension.

All of the above is done using a LOGIN role that has CREATEROLE and CREATEDB.

Extensions are not supposed to implicitly disappear, are they?
Any idea, what we're missing, that might explain pgcrypto's disappearance?
We're stumped for now.

TIA, --DD



Re: Extension disappearing act

От
Tomas Vondra
Дата:

On 6/19/25 15:09, Dominique Devienne wrote:
> Hi. Little mystery we don't understand. v17.
> 
> Create new DB, owned by dedicated new ROLE.
> Create extension (pgcrypto) in our case. Installed in public, owned by
> DB owner role.
> Create schemas and populate them inside the DB.
> This also creates roles associated to those schemas.
> One of the schema is owned by the DB owner (in case that matters).
> Creates functions using pgcrypto, in some of those schemas.
> Drop all schemas (and associated roles), thus pgcrypto-using functins are gone.
> Of course, the DB owner role was not dropped. Can't in fact.
> Somehow, the pgcrypto extension has disappeared, as side-effects of the drops.
> We did a LIBPQ trace of the command to does all the drops,
> and there's no explicit drop of the extension.
> 
> All of the above is done using a LOGIN role that has CREATEROLE and CREATEDB.
> 
> Extensions are not supposed to implicitly disappear, are they?

No, extensions should not disappear.

> Any idea, what we're missing, that might explain pgcrypto's disappearance?
> We're stumped for now.
> 

The only idea I can come up with is that pgcrypto was in one of those
dropped schemas (but I know you're saying it was in public).

Are you able to reproduce this? If yes, can you share a reproducer?


regards

-- 
Tomas Vondra




Re: Extension disappearing act

От
Laurenz Albe
Дата:
On Thu, 2025-06-19 at 15:09 +0200, Dominique Devienne wrote:
> Hi. Little mystery we don't understand. v17.
>
> Create new DB, owned by dedicated new ROLE.
> Create extension (pgcrypto) in our case. Installed in public, owned by
> DB owner role.
> Create schemas and populate them inside the DB.
> This also creates roles associated to those schemas.
> One of the schema is owned by the DB owner (in case that matters).
> Creates functions using pgcrypto, in some of those schemas.
> Drop all schemas (and associated roles), thus pgcrypto-using functins are gone.
> Of course, the DB owner role was not dropped. Can't in fact.
> Somehow, the pgcrypto extension has disappeared, as side-effects of the drops.
> We did a LIBPQ trace of the command to does all the drops,
> and there's no explicit drop of the extension.
>
> All of the above is done using a LOGIN role that has CREATEROLE and CREATEDB.
>
> Extensions are not supposed to implicitly disappear, are they?
> Any idea, what we're missing, that might explain pgcrypto's disappearance?
> We're stumped for now.

So are we.  Why do you keep us guessing instead of posting a reproducer?

Yours,
Laurenz Albe



Re: Extension disappearing act

От
Merlin Moncure
Дата:


On Thu, Jun 19, 2025 at 8:09 AM Dominique Devienne <ddevienne@gmail.com> wrote:
Hi. Little mystery we don't understand. v17.

Create new DB, owned by dedicated new ROLE.
Create extension (pgcrypto) in our case. Installed in public, owned by
DB owner role.
Create schemas and populate them inside the DB.
This also creates roles associated to those schemas.
One of the schema is owned by the DB owner (in case that matters).
Creates functions using pgcrypto, in some of those schemas.
Drop all schemas (and associated roles), thus pgcrypto-using functins are gone.
Of course, the DB owner role was not dropped. Can't in fact.
Somehow, the pgcrypto extension has disappeared, as side-effects of the drops.
We did a LIBPQ trace of the command to does all the drops,

 Suggestion:
1. Turn on statement logging to 'all'.  Make sure times are logged
2. Install a trace. this could be as simple as:
select now(), count(*) FILTER (WHERE extname = 'pgcrypto') from pg_extension ;
\watch
...in psql
3. that should nail the time of the drop. at that time, you can then find the offending statement

merlin