Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail if the replication slots already exists during creation #1049

Open
antonag32 opened this issue Dec 30, 2024 · 4 comments
Open

Don't fail if the replication slots already exists during creation #1049

antonag32 opened this issue Dec 30, 2024 · 4 comments

Comments

@antonag32
Copy link

I am setting up barman automatically through some scripts and it would be helpful to provide some idempotency when creating replication slots. I am specifically talking about the following command:

barman receive-wal --create-slot server-name

If the slot exists the command fails. I was thinking about adding a new flag so the command won't fail if its because the replication slot already exists.

What do you think? I can make a PR if you agree to it.

@barthisrael
Copy link
Contributor

Hello @antonag32,

We don't think that adding a flag to barman recevei-wal to ignore slot creation issues is the way to go.

A possibly better way of handling that would be having Barman to exit with different return codes depending on the issue that it faces. Right now it exits with 0 on success, or with 1 in most cases of errors. But a change in that mechanism requires a deeper analysis.

In any case, even with the current Barman code, which contains no classification of errors with different return codes, you should still be able to provide idempotency through your scripts when running barman recevei-wal --create-slot server-name. You could ignore a failure of barman receive-wal --create-slot server-name by checking that stderr contains a pattern like Replication slot 'SLOT_NAME' already exists when the return code is not 0.

Best regards,
Israel.

@barthisrael
Copy link
Contributor

Hello @antonag32,

After a deeper look around, we think it actually makes sense to add a new flag to barman receive-wal in this specific case.

As we can see in the pg_receivewal docs, there is an option called --if-not-exists:

--if-not-exists
    Do not error out when --create-slot is specified and a slot with the specified name already exists.

We could create a similar option in barman receive-wal to call pg_receivewal with that flag.

What do you think? I can make a PR if you agree to it.

Would you still be willing to contribute a PR to Barman, adding --if-not-exists option to barman receive-wal?
If not, we will take that task over within the development team.

Best regards,
Israel.

@antonag32
Copy link
Author

Hello @barthisrael

I will be happy to contribute. I am a bit busy this week but should be able to start working on a PR next week. Thanks for taking the time to review the issue.

@barthisrael
Copy link
Contributor

Hey @antonag32 ,

I will be happy to contribute. I am a bit busy this week but should be able to start working on a PR next week. Thanks for taking the time to review the issue.

Sure, thank you!

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

No branches or pull requests

2 participants