babelfish-for-postgresql / babelfish_extensions

Babelfish for PostgreSQL provides the capability for PostgreSQL to work with applications written for Microsoft SQL Server. Babelfish understands the SQL Server wire-protocol and T-SQL, the Microsoft SQL Server query and procedural language, so you don’t have to switch database drivers or rewrite all of your application queries.
https://babelfishpg.org/
Apache License 2.0
271 stars 92 forks source link

pgoutput to stream data changes #2868

Closed kranthi1385 closed 2 weeks ago

kranthi1385 commented 3 weeks ago

Hi Experts,

We are trying to configure PGoutput to stream data changes to another destination(flatfile if possible) using logical replication, but we are getting the following error. Can anyone suggest a solution?

ERROR: client sent proto_version=0 but server only supports protocol 1 or higher CONTEXT: slot "repli_slot", output plugin "pgoutput", in the startup callback *

rishabhtanwar29 commented 2 weeks ago

Hi @kranthi1385, it looks like client is sending the proto_version = 0 by default although this is configurable option. You can refer here about all the supported output plugin options. There are different ways to specify this option depending upon the driver you are using. For example, it can be supplied using sql function pg_logical_slot_get_changes as follows:

SELECT * FROM pg_create_logical_replication_slot('test_slot', 'pgoutput', false, true);
SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'proto_version', '1');

You can check this blog here for more details https://medium.com/@film42/getting-postgres-logical-replication-changes-using-pgoutput-plugin-b752e57bfd58 Additionally, you can provide your replication setup details here as well if you face any issue so that we can help debug it further.

kranthi1385 commented 2 weeks ago

@rishabhtanwar29 I have followed the steps provided above but still getting the error.

ERROR: logical decoding output plugin "pgoutput" produces binary output, but function "pg_logical_slot_get_changes(name,pg_lsn,integer,text[])" expects textual data

SQL state: 0A000

rishabhtanwar29 commented 2 weeks ago

My bad, we should be using pg_logical_slot_get_binary_changes function instead of pg_logical_slot_get_changes

kranthi1385 commented 2 weeks ago

@rishabhtanwar29 thanks for the update i am able to connect and get the results I have used pg_logical_slot_get_binary_changes pg_logical_slot_get_changes