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

fix(db-query): use nested query for requeuing FRI prover jobs #399

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions core/lib/dal/sqlx-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2957,6 +2957,39 @@
},
"query": "SELECT * FROM protocol_versions ORDER BY id DESC LIMIT 1"
},
"3665394a2f91f1a07c2c517ae9e75434f9ec12ed4debf370662b8104e015c75f": {
"describe": {
"columns": [
{
"name": "id",
"ordinal": 0,
"type_info": "Int8"
},
{
"name": "status",
"ordinal": 1,
"type_info": "Text"
},
{
"name": "attempts",
"ordinal": 2,
"type_info": "Int2"
}
],
"nullable": [
false,
false,
false
],
"parameters": {
"Left": [
"Interval",
"Int2"
]
}
},
"query": "\n UPDATE prover_jobs_fri\n SET status = 'queued', attempts = attempts + 1, updated_at = now(), processing_started_at = now()\n WHERE id in (\n SELECT id\n FROM prover_jobs_fri\n WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'failed' AND attempts < $2)\n FOR UPDATE SKIP LOCKED\n )\n RETURNING id, status, attempts\n "
},
"36c483775b604324eacd7e5aac591b927cc32abb89fe1b0c5cf4b0383e9bd443": {
"describe": {
"columns": [
Expand Down Expand Up @@ -6386,39 +6419,6 @@
},
"query": "\n SELECT id, circuit_input_blob_url FROM prover_jobs\n WHERE status='successful' AND is_blob_cleaned=FALSE\n AND circuit_input_blob_url is NOT NULL\n AND updated_at < NOW() - INTERVAL '30 days'\n LIMIT $1;\n "
},
"892ad2bed255401e020b4cf89c9e43e32c333dc6627e1e2d2535e13b73d1c508": {
"describe": {
"columns": [
{
"name": "id",
"ordinal": 0,
"type_info": "Int8"
},
{
"name": "status",
"ordinal": 1,
"type_info": "Text"
},
{
"name": "attempts",
"ordinal": 2,
"type_info": "Int2"
}
],
"nullable": [
false,
false,
false
],
"parameters": {
"Left": [
"Interval",
"Int2"
]
}
},
"query": "\n UPDATE prover_jobs_fri\n SET status = 'queued', attempts = attempts + 1, updated_at = now(), processing_started_at = now()\n WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2)\n OR (status = 'failed' AND attempts < $2)\n RETURNING id, status, attempts\n "
},
"8996a1794585dfe0f9c16a11e113831a63d5d944bc8061d7caa25ea33f12b19d": {
"describe": {
"columns": [
Expand Down
11 changes: 8 additions & 3 deletions core/lib/dal/src/fri_prover_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,14 @@ impl FriProverDal<'_, '_> {
"
UPDATE prover_jobs_fri
SET status = 'queued', attempts = attempts + 1, updated_at = now(), processing_started_at = now()
WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)
OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2)
OR (status = 'failed' AND attempts < $2)
WHERE id in (
SELECT id
FROM prover_jobs_fri
WHERE (status = 'in_progress' AND processing_started_at <= now() - $1::interval AND attempts < $2)
OR (status = 'in_gpu_proof' AND processing_started_at <= now() - $1::interval AND attempts < $2)
OR (status = 'failed' AND attempts < $2)
FOR UPDATE SKIP LOCKED
)
RETURNING id, status, attempts
",
&processing_timeout,
Expand Down