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

Detect dead jobs and set to 'failed' status #806

Merged
merged 2 commits into from
Sep 18, 2021

Conversation

john-shaffer
Copy link
Contributor

I've only implemented this for deploy jobs since that's the only place I've seen a problem, but we could pretty easily use this pattern for every job type if needed.

@john-shaffer
Copy link
Contributor Author

#585 does mention other stages, so we should implement this for the other three job_types as well.

$locked = intval( $wpdb->get_row( $query )->lck );
if ( ! $locked ) {
WsLog::l( 'Failed to acquire "wp2static_jobs_deploying" lock.' );
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this still let registered post deployment hooks fire? ie, if S3 deploy fails and we return here, might it still call CF invalidation unnecessarily?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we're not catching the exceptions so it will not run post-deploy hooks in that case.

$deployer
);
} finally {
$wpdb->query( "DO RELEASE_LOCK('wp2static_jobs_deploying')" );
Copy link
Contributor

Choose a reason for hiding this comment

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

If this ever fails, do we have a way to manually clean up, like with caches?

Copy link
Contributor Author

@john-shaffer john-shaffer Sep 18, 2021

Choose a reason for hiding this comment

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

In testing, releasing here was not even necessary because WP apparently closes the connection after the request, which implicitly releases the locks. If we ever run into a problem with a customized WP or something, we can add a config option to turn this off.

@leonstafford
Copy link
Contributor

@john-shaffer added cpl minor comments/questions.

Also, if we implement this for the crawling stage, will we still be able to catch and nicely log specific crawl errors, like network timeouts?

You suggested we do for other job types - wanna do in this PR or create new tickets for later?

@leonstafford leonstafford merged commit ead7307 into elementor:develop Sep 18, 2021
@john-shaffer john-shaffer deleted the detect-failed-jobs branch November 9, 2021 02:51
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