Skip to content

Add migration to create logical replication slot - #4946

Open
DilwoarH wants to merge 1 commit into
mainfrom
create-replication-slot
Open

DilwoarH wants to merge 1 commit into
mainfrom
create-replication-slot

Conversation

@DilwoarH

@DilwoarH DilwoarH commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

This creates a wal2json replication slot to allow us to listen to changes to the notifications table.

@DilwoarH
DilwoarH force-pushed the create-replication-slot branch 2 times, most recently from a778ebf to 95f43b1 Compare September 1, 2026 12:06
@DilwoarH
DilwoarH requested review from klssmith and risicle September 2, 2026 09:52
@klssmith

klssmith commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Can we test this on a dev env? It seems like we're going to run into the problem of output_plugin_libraries now needing to include wal2json. This PR added that to the Concourse test image, but I'd expect us to need the same change in our environments

@DilwoarH

DilwoarH commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Can we test this on a dev env?

Good point, Will run another test.

It seems like we're going to run into the problem of output_plugin_libraries now needing to include wal2json. This PR added that to the Concourse test image, but I'd expect us to need the same change in our environments

I noticed that I missed the default ones, it should have been:

pgoutput, test_decoding, wal2json

I'll have a look at adding this in.

@risicle

risicle commented Sep 2, 2026

Copy link
Copy Markdown
Member

Dude before we consider enabling this for production we need to choose and set a max_slot_wal_keep_size. I think it's currently set to "infinite", which means this would just start eating up our disk space forever if nothing were consuming the slot.

@DilwoarH

DilwoarH commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Dude before we consider enabling this for production we need to choose and set a max_slot_wal_keep_size. I think it's currently set to "infinite", which means this would just start eating up our disk space forever if nothing were consuming the slot.

Yeah - I'm avoiding merging this in before the processing code (#4930).

@DilwoarH

DilwoarH commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Can we test this on a dev env?

Good point, Will run another test.

It seems like we're going to run into the problem of output_plugin_libraries now needing to include wal2json. This PR added that to the Concourse test image, but I'd expect us to need the same change in our environments

I noticed that I missed the default ones, it should have been:

pgoutput, test_decoding, wal2json

I'll have a look at adding this in.

A PR was merged to fix the concourse test dbs - #4955

@DilwoarH

DilwoarH commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Can we test this on a dev env? It seems like we're going to run into the problem of output_plugin_libraries now needing to include wal2json. This PR added that to the Concourse test image, but I'd expect us to need the same change in our environments

@klssmith additional test ran on dev-d - worked fine.

@DilwoarH

DilwoarH commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Todo before merging this in:

  • Set max size limit
  • Set output_plugin_libraries

@DilwoarH

DilwoarH commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@klssmith

klssmith commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

I realised this will work in our environments now because we're using Postgres 15.17, and the restriction on output_plugin_libraries was only introduced in 15.19. But we will presumably have issues when we do upgrade Postgres - it feels like it would be best just to update output_plugin_libraries now before we're using wal2json and in case we don't remember we need to do that before upgrading Postgres. That wouldn't block this PR but might be something to discuss

@risicle

risicle commented Sep 3, 2026

Copy link
Copy Markdown
Member

@risicle - looks like there is a default limit set of 2GB already:

That's not the same config setting.

@DilwoarH

DilwoarH commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@risicle - looks like there is a default limit set of 2GB already:

That's not the same config setting.

PR added: https://github.com/alphagov/notifications-aws/pull/3094

@DilwoarH

DilwoarH commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

#3094 has been merged in but requires reboot to apply changes

@DilwoarH

DilwoarH commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

#3094 has been merged in but requires reboot to apply changes

Restart not required: https://github.com/alphagov/notifications-aws/pull/3096

@DilwoarH

DilwoarH commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@risicle @klssmith - are you both happy with this now?

@klssmith

klssmith commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

It doesn't block this, but I still think we need a definite plan or PR for when we'll change output_plugin_libraries to include wal2json. Otherwise it will get forgotten about and cause an incident when the Postgres version is upgraded and our code no longer works

@DilwoarH

DilwoarH commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

It doesn't block this, but I still think we need a definite plan or PR for when we'll change output_plugin_libraries to include wal2json. Otherwise it will get forgotten about and cause an incident when the Postgres version is upgraded and our code no longer works

PR added to support this:

https://github.com/alphagov/notifications-aws/pull/3100

@DilwoarH
DilwoarH force-pushed the create-replication-slot branch from 95f43b1 to 247589b Compare September 9, 2026 14:25
@DilwoarH
DilwoarH force-pushed the create-replication-slot branch from 247589b to 38c43f5 Compare September 25, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants