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

Log a warning if PG startup takes too long #924

Merged
merged 4 commits into from
Oct 8, 2023

Conversation

pjsier
Copy link
Contributor

@pjsier pjsier commented Oct 7, 2023

Adds a warning message using the suggested implementation in #810. Thanks for the recommended approach in the ticket! This one seemed straightforward enough that local tests would do, which I ran by adding a delay to instantiate_tables.

I'm getting a clippy error locally for having Deserialize on a type with methods using unsafe, but it looks like that might be a more significant update.

Fixes #810

@@ -110,8 +114,18 @@ impl PgConfig {

pub async fn resolve(&mut self, id_resolver: IdResolver) -> crate::Result<Sources> {
let pg = PgBuilder::new(self, id_resolver).await?;

let instantiate_tables = pg.instantiate_tables();
pin_mut!(instantiate_tables);
Copy link
Member

Choose a reason for hiding this comment

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

I think this should go inside the fn instantiate_tables() because otherwise you are not simultaneously instantiating tables AND functions. Instead, you instantiate tables for 5 seconds or until complet, and only then start instantiating functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the mixup there! This updated version should work as expected, but I wrapped the entire instantiate_tables function because there are multiple futures awaited inside of it and I wasn't sure the best way to go about that

@pjsier pjsier force-pushed the 810-log-pg-startup-warning branch from c2591d9 to c8e9c0e Compare October 8, 2023 00:57
This makes the functionality reusable
@nyurik
Copy link
Member

nyurik commented Oct 8, 2023

@pjsier I created a PR against your PR - pjsier#1
I think this approach is a bit cleaner and easier to follow, plus i suspect it won't cause Clippy to complain (I have no idea why it was doing that to begin with).
If you agree, simply merge my PR into yours, and I will approve it.

Cleaner approach to timeout reporting
@nyurik nyurik enabled auto-merge (squash) October 8, 2023 19:52
Copy link
Member

@nyurik nyurik left a comment

Choose a reason for hiding this comment

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

thx!

@nyurik nyurik merged commit 321a969 into maplibre:main Oct 8, 2023
24 checks passed
@nyurik nyurik mentioned this pull request Oct 20, 2023
5 tasks
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.

Log a warning if PG startup takes too long
2 participants