Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Fix bug with pending patch removal #78

Merged
merged 2 commits into from
Jun 7, 2018
Merged

Conversation

veruu
Copy link
Contributor

@veruu veruu commented Jun 6, 2018

Fix bug with pending patch removal

If the patch moved between Patchwork projects during the time it's being
tested, it gets stuck in the pending patch table. Since patch IDs are
unique per instance (and don't depend on the project), change the
pending patch table to contain Patchwork instance's base URL in addition
to ID of (base URL, patch ID) pair. This solves the problem with patch
removal from pending table, while keeps the original information needed
for proper testing.

Also introduce a way to migrate the database after upgrades since it's
needed for this change.

Fixes #57

Signed-off-by: Veronika Kabatova vkabatov@redhat.com

@coveralls
Copy link

coveralls commented Jun 6, 2018

Pull Request Test Coverage Report for Build 222

  • 5 of 5 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 53.574%

Totals Coverage Status
Change from base Build 215: -0.04%
Covered Lines: 682
Relevant Lines: 1273

💛 - Coveralls

Copy link
Contributor

@spbnick spbnick left a comment

Choose a reason for hiding this comment

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

This still doesn't update get_last_pending_patch, get_last_pending_patch_date, and get_expired_pending_patches, which would break sktm in various ways. Search for pendingpatches in sktm/db.py to find all the places to update. Please also update the FIXME above the database creation script. Thank you!

README.md Outdated
For example, if the database path is `.sktm.db` and migration `01-pending.sql`
is being applied, the command will be

sqlite3 .sktm.db < 01-pending.sql
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we maybe have this (and paragraph above) use ~/.sktm.db so it works as is with the default install, regardless of the current directory (which will probably be db_migrations)?

Not necessary for my ACK.

@@ -0,0 +1,11 @@
CREATE TABLE pendingpatches_tmp(id INTEGER PRIMARY KEY, pdate TEXT,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have this named pendingpatches_new for clarity?

Not necessary for my ACK.

sktm/db.py Outdated
patchsource_id INTEGER,
timestamp INTEGER,
FOREIGN KEY(patchsource_id) REFERENCES patchsource(id)
baseurl TEXT,
Copy link
Contributor

@spbnick spbnick Jun 6, 2018

Choose a reason for hiding this comment

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

We need to add PRIMARY KEY(baseurl, id) next, in a separate PR, to fix the bug mentioned in set_patchset_pending description.

Not necessary for my ACK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't be hard to add here 👍

sktm/db.py Outdated
base URL").
specifed patch date, for specified Patchwork base URL, and marked with
current timestamp. Replace any previously added patches with the same
ID (bug: should be "same ID and base URL").
Copy link
Contributor

Choose a reason for hiding this comment

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

This bug.

@veruu veruu requested review from spbnick and removed request for spbnick June 6, 2018 12:25
@veruu
Copy link
Contributor Author

veruu commented Jun 6, 2018

I must have messed up something during the rebases because I'm pretty sure I fixed those methods yesterday. Ah well, thanks for noticing!

@veruu veruu force-pushed the bug_57 branch 4 times, most recently from 0e49f12 to e9e5ddf Compare June 6, 2018 15:33
@spbnick
Copy link
Contributor

spbnick commented Jun 7, 2018

I dug around the SQL syntax a little and it seems we can simply change the delete statement to only match the baseurl and the patch id like this:

DELETE FROM pendingpatches
       WHERE patchsource_id IN (SELECT DISTINCT id
                                       FROM patchsource
                                       WHERE baseurl = ?) AND
             id = ?

E.g.:

DELETE FROM pendingpatches
       WHERE patchsource_id IN (SELECT DISTINCT id
                                       FROM patchsource
                                       WHERE baseurl = "https://patchwork.kernel.org") AND
             id = 10451123

This way we won't have to update the schema at all, nor have duplication, nor so many code changes.
It will still be a hack against the schema, and we'll still need to fix it later, though.
What do you think?

@veruu
Copy link
Contributor Author

veruu commented Jun 7, 2018

That should work too. Agreed that we have a lot of DB stuff to fix later, and are only pushing there more and more things that we'll need to eventually fix. But for now, it should be fine.

I'd still keep the migration infrastructure in a separate commit though, we'd need it :)

@spbnick
Copy link
Contributor

spbnick commented Jun 7, 2018

Yes, let's keep the migration infrastructure. Thanks :)

veruu added 2 commits June 7, 2018 10:08
If the patch moved between Patchwork projects during the time it's being
tested, it gets stuck in the pending patch table. Since patch IDs are
unique per instance (and don't depend on the project), change the
DELETE statement to get all known patchsource_ids with given URL and
then remove the appropriate patch from the table. This allows us to
function independently of where the patch moved.

Fixes cki-project#57

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
We will need it soon.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
@veruu
Copy link
Contributor Author

veruu commented Jun 7, 2018

@spbnick updated, and added a comment about patchsource table into issue #80

Copy link
Contributor

@spbnick spbnick left a comment

Choose a reason for hiding this comment

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

Looks great, thank you, Veronika :)!

@spbnick spbnick merged commit 1b4ef7f into cki-project:master Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants