Skip to content

Instantly share code, notes, and snippets.

@alexhwoods
Last active May 5, 2023 13:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexhwoods/4c4c90d83db3c47d9303cb734135130d to your computer and use it in GitHub Desktop.
Save alexhwoods/4c4c90d83db3c47d9303cb734135130d to your computer and use it in GitHub Desktop.
Fixing "must be superuser to create FOR ALL TABLES publication" error from Debezium with PostgreSQL on Aiven

Issue

You're trying to use Kafka Connect, using the Debezium to Postgres, and your Postgres database is running on Aiven. You have pgoutput selected as the plugin name (this is the best choice).

You're getting this error: Caused by: org.postgresql.util.PSQLException: ERROR: must be superuser to create FOR ALL TABLES publication.

Why This is Happening

Aiven doesn't allow you to have a superuser. Debezium tries to create a publication, and fails, because it's not using a superuser.

How To Fix It

We have to create the publication before configuring the connector. Publications are database specific, so you have to do this when you're connected to the database you're going to use for CDC.

There is a package called aiven-extras that allows you to create a publication.

  1. Connect to the database you'll use.
\connect foodb;
  1. Install aiven-extras
CREATE EXTENSION aiven_extras CASCADE;
  1. Create a publication for all tables
SELECT *
FROM aiven_extras.pg_create_publication_for_all_tables('dbz_publication', 'INSERT,UPDATE,DELETE');

It must be called dbz_publication. That is what Debezium is expecting.

Now, you can run your connector and it should work (or you might have other, likely fixable issues).

@troysellers
Copy link

It seems the name of that publication has changed

SELECT * FROM aiven_extras.pg_create_publication_for_all_tables('debezium_publication', 'INSERT,UPDATE,DELETE')'
was required to get this working for me...

@alexhwoods
Copy link
Author

Could be; I haven't touched debezium + Aiven in a couple years now. Thanks for the update!

@jclarysse
Copy link

No, the default value is still dbz_publication if you don't change it. Aiven official documentation mentions this fix, including the need to check for the right publication name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment