Bucardo, Postgres, and max_stack_depth

It’s not an error you see very often, but if you’re wanting to do logical replication for postgres older than v10, Bucardo is a good way to do it. You can use Bucardo, for instance, to replicate data to a new version of Postgres, or you could use it to migrate out of RDS, since you don’t need to be a superuser. For that matter, bucardo remains useful as a replication means for that very reason – you don’t need superuser for anything. You just need to be able to create a schema and update the schema of the tables you want to replicate.

Anyways, a default Postgres instance won’t quite work, and you’ll see errors like this:

“KID Warning! Aborting due to exception for public.my_big_table 😕 Error was DBD :: Pg :: db do failed: ERROR: stack depth limit exceeded \ nHINT: Increase the configuration parameter “max_stack_depth” (currently 2048kB)”

Notice that 2048kB? That’s the default max_stack_depth value in (at least Postgres 9.6 and 10). That’s set in postgres.conf, so update it to 6MB and you’ll be set.

This is a blog post that mentions something similar, in case you’re looking for others using Bucardo: