Skip to content

Conversation

archessmn
Copy link
Member

Do database connection monitoring slightly better

@archessmn archessmn force-pushed the int-200-healthz-should-check-database-status branch from 03bb374 to 18be8a3 Compare October 7, 2024 19:45
@jenkins-ystv
Copy link

jenkins-ystv bot commented Oct 7, 2024

Deployed a preview of this PR to https://pr-167-internal.dev.ystv.co.uk

1 similar comment
@jenkins-ystv
Copy link

jenkins-ystv bot commented Oct 7, 2024

Deployed a preview of this PR to https://pr-167-internal.dev.ystv.co.uk

Copy link
Member

@markspolakovs markspolakovs left a comment

Choose a reason for hiding this comment

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

Not against it going in now in its current state, but some things for your consideration.

console.error(
`Database connection attempt ${connectionAttempts} failed, retrying...`,
);
await sleep(5000);
Copy link
Member

@markspolakovs markspolakovs Oct 7, 2024

Choose a reason for hiding this comment

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

Should we bail immediately and not do the whole retry loop / is this delaying the inevitable? Would also simplify this code substantially.

Copy link
Member Author

Choose a reason for hiding this comment

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

My reasoning was just to give it a bit of time to get started so it wouldn't just fail instantly and keep getting redeployed if it had an issue on the first connection

Copy link
Member

Choose a reason for hiding this comment

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

Possibly? But in my head that'd only be the case if the database server is the one that's taking a while to start, which it should almost never be in production (the Prisma connection should block if it isn't ready yet), so we'd want to fail fast if something is up with the DB.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's within 15 seconds, it's not going to cause a massive issue I don't think

@archessmn archessmn merged commit d55946f into main Oct 8, 2024
3 checks passed
@archessmn archessmn deleted the int-200-healthz-should-check-database-status branch October 8, 2024 15:36
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