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

harmony: Fix task reclaim on restart #11498

Merged
merged 1 commit into from
Dec 7, 2023
Merged

harmony: Fix task reclaim on restart #11498

merged 1 commit into from
Dec 7, 2023

Conversation

magik6k
Copy link
Contributor

@magik6k magik6k commented Dec 7, 2023

Related Issues

Proposed Changes

On restart harmony would fail to reclaim tasks claimed because the owner_id was already non-null. With this change we just take ownership of all tasks which are recovered

2023-12-07T11:26:05.521+0100	DEBUG	harmonydb	harmonydb/harmonydb.go:133	SQL run	{"query": "\n\t\t\tWITH upsert AS (\n\t\t\t\tUPDATE harmony_machines\n\t\t\t\tSET cpu = $2, ram = $3, gpu = $4, last_contact = CURRENT_TIMESTAMP\n\t\t\t\tWHERE host_and_port = $1\n\t\t\t\tRETURNING id\n\t\t\t),\n\t\t\tinserted AS (\n\t\t\t\tINSERT INTO harmony_machines (host_and_port, cpu, ram, gpu, last_contact)\n\t\t\t\tSELECT $1, $2, $3, $4, CURRENT_TIMESTAMP\n\t\t\t\tWHERE NOT EXISTS (SELECT id FROM upsert)\n\t\t\t\tRETURNING id\n\t\t\t)\n\t\t\tSELECT id FROM upsert\n\t\t\tUNION ALL\n\t\t\tSELECT id FROM inserted;\n\t\t", "err": null, "rowCt": 1, "milliseconds": 51}
2023-12-07T11:26:05.532+0100	DEBUG	harmonydb	harmonydb/harmonydb.go:133	SQL run	{"query": "DELETE FROM harmony_machines WHERE last_contact < CURRENT_TIMESTAMP - INTERVAL '1 MILLISECOND' * $1 ", "err": null, "rowCt": 0, "milliseconds": 11}
2023-12-07T11:26:05.532+0100	INFO	harmonytask	resources/resources.go:77	Cleaned up machines	{"count": 0}
2023-12-07T11:26:05.544+0100	DEBUG	harmonydb	harmonydb/harmonydb.go:133	SQL run	{"query": "SELECT id, name from harmony_task WHERE owner_id=$1", "err": null, "rowCt": 8, "milliseconds": 11}
2023-12-07T11:26:05.545+0100	DEBUG	harmonydb	harmonydb/harmonydb.go:133	SQL run	{"query": "UPDATE harmony_task SET owner_id=$1 WHERE id=$2 AND owner_id IS NULL", "err": null, "rowCt": 0, "milliseconds": 1}
2023-12-07T11:26:05.545+0100	INFO	harmonytask	harmonytask/task_type_handler.go:97	did not accept task	{"task_id": "20241", "reason": "already Taken", "name": "WdPostRecover"}
2023-12-07T11:26:05.557+0100	DEBUG	harmonydb	harmonydb/harmonydb.go:133	SQL run	{"query": "SELECT epoch FROM mining_tasks WHERE task_id = $1", "err": null, "rowCt": 1, "milliseconds": 11}
2023-12-07T11:26:05.558+0100	DEBUG	harmonydb	harmonydb/harmonydb.go:133	SQL run	{"query": "UPDATE harmony_task SET owner_id=$1 WHERE id=$2 AND owner_id IS NULL", "err": null, "rowCt": 0, "milliseconds": 0}
2023-12-07T11:26:05.558+0100	INFO	harmonytask	harmonytask/task_type_handler.go:97	did not accept task	{"task_id": "24308", "reason": "already Taken", "name": "WinPost"}

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • If the PR affects users (e.g., new feature, bug fix, system requirements change), update the CHANGELOG.md and add details to the UNRELEASED section.
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@magik6k magik6k requested a review from a team as a code owner December 7, 2023 11:23
@snadrus snadrus merged commit cf8fed9 into master Dec 7, 2023
88 of 89 checks passed
@snadrus snadrus deleted the fix/harmony-reclaim branch December 7, 2023 15:46
rjan90 pushed a commit that referenced this pull request Dec 11, 2023
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.

4 participants