Skip to content

Conversation

iambriccardo
Copy link
Contributor

@iambriccardo iambriccardo commented Jul 23, 2025

This PR implements sane defaults for the Postgres connection to avoid having the database misconfigured.

@iambriccardo iambriccardo marked this pull request as ready for review July 23, 2025 12:04
@iambriccardo iambriccardo requested a review from a team as a code owner July 23, 2025 12:04
statement_timeout: 7_200_000, // 2 hours in milliseconds
lock_timeout: 30_000, // 30 seconds in milliseconds
idle_in_transaction_session_timeout: 300_000, // 5 minutes in milliseconds
application_name: "etl".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does Postgres to Postgres replication use for the timeout settings? Ok to use etl as application name for now, but we should later on use separate names for table sync and apply workers, probably same or similar as slot names.

Copy link
Contributor Author

@iambriccardo iambriccardo Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, I was considering using different names but yeah, let's do in it in a follow up, since it might add a lot of lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked the code and online, it seems like that the timeouts are set on a per subscription basis where the subscription contains the connection string. This means that no timeout is used by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should enable users to configure it in the future and keep it disabled for now, this way we can avoid possible problems related to timeouts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's disable statement_timeout and can keep the other timeouts at their current values in the PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By disable I meant that statement_timeout is set to 0. If we omit it it will take the default value set for the role we use to connect which may or may not be 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@iambriccardo iambriccardo requested a review from imor July 24, 2025 10:58
@iambriccardo iambriccardo merged commit 69388b0 into main Jul 25, 2025
3 checks passed
@iambriccardo iambriccardo deleted the riccardobusetti/etl-129-set-sane-options-when-connecting-to-postgres branch July 25, 2025 08:41
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.

2 participants