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

Store task prerequisites in their own DB table #3863

Merged
merged 9 commits into from
Nov 4, 2020

Conversation

MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented Oct 13, 2020

These changes close #3752

Instead of storing task prerequisites as a JSON string inside the task_pool table, remove the satisfied column from task_pool and introduce a task_prerequisites table.

Note: This PR removes the ability to restart a Cylc 7 suite.

For the flow (where foo.1 fails)

P1 = foo & ipsum:custom1 => bar

the task_prerequisites table has the form:

cycle* TEXT name* TEXT prereq_name* TEXT prereq_cycle* TEXT prereq_output* TEXT satisfied TEXT
1 bar foo 1 succeeded 0
1 bar ipsum 1 I'm a custom task message satisfied naturally

where asterisk in the column header denotes primary key.

A task's prerequisites are inserted into the task_prerequisites table when the task is added to the runahead pool (if a task has no prerequisites, no entry is inserted to the task_prerequisites table). The task_prerequisites table is updated at the same time as before when the prerequisites used to be updated in the task_pool table.

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Appropriate tests are included (functional).
  • Change log entry included
  • No documentation update required.
  • No dependency changes.

@MetRonnie MetRonnie added this to the cylc-8.0a3 milestone Oct 13, 2020
@MetRonnie MetRonnie self-assigned this Oct 13, 2020
@oliver-sanders
Copy link
Member

Looks good to me, note to others, this change does not have an upgrader for the database. We have abandoned the idea of maintaining restart compatibility with Cylc7 due to installation changes amongst other things so this is fine. Just be aware that cylc restart will not work with previously run workflows on this branch.

@MetRonnie
Copy link
Member Author

Does that mean that the following test:

# Compat: Cylc<8
# Test the upgrade of the old *retrying states to the new xtrigger based
# retry mechanism.
. "$(dirname "$0")/test_header"
set_test_number 10
install_suite
# install the cylc7 restart database
cp "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/.service/db" \
"${HOME}/cylc-run/${SUITE_NAME}/.service/db"

which is failing due to

sqlite3.OperationalError: table task_pool_checkpoints has 7 columns but 6 values were supplied

can be removed?

@oliver-sanders
Copy link
Member

Sure, but if removing, remove all upgraders and their associated tests.

@MetRonnie
Copy link
Member Author

Still need to detect when trying to restart a Cylc 7 suite and give a useful error message

@MetRonnie
Copy link
Member Author

Would it be worth renaming the db file in order to detect when the user is trying to restart a Cylc < 8.0a3 suite?

@oliver-sanders
Copy link
Member

oliver-sanders commented Oct 14, 2020

Would it be worth renaming the db file in order to detect when the user is trying to restart a Cylc < 8.0a3 suite?

The Cylc version of the current run (even if the suite is stopped it can still be thought of as the current "run") has been stored in the database since Cylc 7.something:

$ sqlite3 <path-to-suite>/.service/db 'SELECT value FROM suite_params WHERE key = "cylc_version";'

Wasn't expecting this as part of this PR but if you're happy to take a crack at it that would be great. If the SQL execution fails then assume that the Cylc version is less than 8.

@MetRonnie
Copy link
Member Author

Is there any reason not to rename the db file, though? It would make the logic simpler

@oliver-sanders
Copy link
Member

oliver-sanders commented Oct 14, 2020

Yes, people may be using it, if an SQL call is too much work why not use the presence of the flow.cylc file?

Note we don't really need to worry about inter-version compatibility between alpha releases.

@oliver-sanders oliver-sanders mentioned this pull request Oct 15, 2020
11 tasks
@MetRonnie MetRonnie marked this pull request as ready for review October 15, 2020 17:55
Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

Looks good, works ok.

One thing left to do, the task_pool table is housekept so as to keep it in sync with the task pool. The same logic will need to apply to the task_prereqs table otherwise it will continue to grow indefinitely.

Had a quick fish about in the code and it looks like the suite_db_mgr wipes and rebuilds the task_pool and it's related tables for each batch of changes 🤮. The rundb performs all queued insertions and deletions in the same transition so that's probably not as bad as it sounds (depending on the implementation of the database), presumably just means sqlite has to do a bit more legwork to compute what's actually changed?

Probs best to turn a blind eye to this and just fit the task_prerequsites table into the existing global-update pattern. Perhaps in a later Cylc8 version as we try to make the main loop more async we will make DB updates more event-driven and remove this per-loop global-update logic in the process.

@MetRonnie
Copy link
Member Author

Probs best to turn a blind eye to this and just fit the task_prerequsites table into the existing global-update pattern.

Like this: 01e0798 ?

@MetRonnie
Copy link
Member Author

@oliver-sanders Looks like that will need a task_prerequisites_checkpoints table, the absence of which seems to be causing tests/k/restart/19-checkpoint.t to fail now

@MetRonnie MetRonnie marked this pull request as draft October 16, 2020 15:18
@oliver-sanders
Copy link
Member

Ah, perhaps disable that test for now and add a comment to the checkpoints issue.

@oliver-sanders
Copy link
Member

To checkpoint or not to checkpoint?!

@hjoliver hjoliver added the BLOCKED This can't happen until something else does label Oct 22, 2020
@hjoliver
Copy link
Member

BLOCKED by #3864

@oliver-sanders
Copy link
Member

Can we just disable these tests for now and add a note to #3864 for now, then reinstate checkpoint functionality later if required?

@hjoliver
Copy link
Member

Can we just disable these tests for now and add a note to #3864 for now, then reinstate checkpoint functionality later if required?

We could, but is there any reason we can't make a quick decision on removing named checkpointing. All the facts are "on the table" already.

@MetRonnie
Copy link
Member Author

If named checkpoints are removed does that mean automatic checkpoints are also removed?

@oliver-sanders
Copy link
Member

oliver-sanders commented Oct 26, 2020

We could, but is there any reason we can't make a quick decision on removing named checkpointing

Perhaps but it's a bit off topic for this PR to go removing all of the named checkpointing logic.

If named checkpoints are removed does that mean automatic checkpoints are also removed?

Any logic relating to the checkpoint tables or cylc *checkpoint commands would be up for removal. (Any use of the word "checkpoint" referring to a non-checkpoint table would stay).

@hjoliver
Copy link
Member

hjoliver commented Oct 26, 2020

We could, but is there any reason we can't make a quick decision on removing named checkpointing

Perhaps but it's a bit off topic for this PR to go removing all of the named checkpointing logic.

Arguable, but fair enough - my feeling was, this PR breaks checkpointing as-is, so let's wait on the checkpointing decision to know if this PR should be amended or not.

Moot point now, as @dpmatthews has agreed on removal on Element chat - I'll remove the blocked label...

@hjoliver hjoliver removed the BLOCKED This can't happen until something else does label Oct 26, 2020
@MetRonnie MetRonnie marked this pull request as ready for review October 27, 2020 10:06
Previously we were abusing the task_pool table by storing prereqs as a 
JSON string in a column there. Now, the prereqs are stored in the new 
task_prerequisites table instead.
Because we are droppping the idea of being able to restart a Cylc 7
suite in Cylc 8
If incompatible or missing db, raise meaningful exception
Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

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

Great, thanks @MetRonnie 🎉

@hjoliver hjoliver merged commit 06455a2 into cylc:master Nov 4, 2020
@MetRonnie MetRonnie deleted the prereq-db branch November 4, 2020 11:08
@hjoliver hjoliver modified the milestones: cylc-8.0a3, cylc-8.0b0 Feb 25, 2021
@MetRonnie MetRonnie added the db change Change to the workflow database structure label Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db change Change to the workflow database structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better DB task pool prerequisite storage
3 participants