Menu

Postgres said DROP OWNED worked. DROP ROLE disagreed.
📰

Postgres said DROP OWNED worked. DROP ROLE disagreed.

DEV Community: database·Niyi Gbodimowo·11 days ago
#utz2fX4n
#devtodatabase#devto#dev#role#drop
Long article (795 words) — no AI summary yet.
Reading 0:00
15s threshold

I'm the founder of Kilimanjaro , and this week's note is from the unglamorous end of the job: tearing down.

When a customer project is removed, we remove the database role that belonged to it. It is the last step of a cleanup that is supposed to leave nothing behind. One day that last step started failing, and it kept failing in a way that made no sense for about an afternoon.

The symptom

The cleanup did what every Postgres guide says to do:

DROP OWNED BY r ; DROP ROLE r ;

Enter fullscreen mode

Exit fullscreen mode

DROP OWNED reported success. DROP ROLE then failed, every time:

ERROR: role "r" cannot be dropped because some objects depend on it DETAIL: privileges for function pg_advisory_lock(bigint)

Enter fullscreen mode

Exit fullscreen mode

That message is the whole mystery. DROP OWNED had just said it removed everything the role owned and every privilege it held.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.