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

[23.2] Set metadata states on dataset association, not dataset #17474

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

mvdbeek
Copy link
Member

@mvdbeek mvdbeek commented Feb 14, 2024

Fixes an issue that @natefoo reported, where other users could get the dataset state to change to FAILED_METADATA on the source.

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@github-actions github-actions bot added the area/database Galaxy's database or data access layer label Feb 14, 2024
@github-actions github-actions bot added this to the 23.2 milestone Feb 14, 2024
@mvdbeek
Copy link
Member Author

mvdbeek commented Feb 14, 2024

This is a minimal fix, we should also split the states between valid dataset states and valid dataset instance states, and have the state setter dispatch to the correct table if metadata states are being set.

Copy link
Member

@natefoo natefoo left a comment

Choose a reason for hiding this comment

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

Thanks!

@natefoo
Copy link
Member

natefoo commented Feb 14, 2024

Existing servers may want to do something like:

galaxy_main=> SELECT count(*) FROM dataset WHERE state = 'failed_metadata';
 count
-------
  8816
(1 row)

galaxy_main=> SELECT count(*) FROM dataset WHERE job_id IS null AND state = 'failed_metadata';
 count
-------
   377
(1 row)

galaxy_main=> BEGIN;
galaxy_main=> UPDATE dataset AS d SET state = j.state FROM job AS j WHERE d.job_id = j.id AND d.state = 'failed_metadata';
UPDATE 8439
galaxy_main=> UPDATE dataset SET state = 'ok' WHERE state = 'failed_metadata';
UPDATE 377
galaxy_main=> COMMIT; -- i did rollback for now though

@jdavcs
Copy link
Member

jdavcs commented Feb 14, 2024

Existing servers may want to do something like:

galaxy_main=> SELECT count(*) FROM dataset WHERE state = 'failed_metadata';
 count
-------
  8816
(1 row)

galaxy_main=> SELECT count(*) FROM dataset WHERE job_id IS null AND state = 'failed_metadata';
 count
-------
   377
(1 row)

galaxy_main=> BEGIN;
galaxy_main=> UPDATE dataset AS d SET state = j.state FROM job AS j WHERE d.job_id = j.id AND d.state = 'failed_metadata';
UPDATE 8439
galaxy_main=> UPDATE dataset SET state = 'ok' WHERE state = 'failed_metadata';
UPDATE 377
galaxy_main=> COMMIT; -- i did rollback for now though

I think SET d.state (d missing in first UPDATE?)

@natefoo
Copy link
Member

natefoo commented Feb 14, 2024

UPDATE always works on the table directly following UPDATE afaik. Tried it with the alias and I got this:

galaxy_main=> UPDATE dataset AS d SET d.state = j.state FROM job AS j WHERE d.job_id = j.id AND d.state = 'failed_metadata';
ERROR:  column "d" of relation "dataset" does not exist
LINE 1: UPDATE dataset AS d SET d.state = j.state FROM job AS j WHER...

@jdavcs
Copy link
Member

jdavcs commented Feb 14, 2024

UPDATE always works on the table directly following UPDATE afaik. Tried it with the alias and I got this:

Thanks for checking, I didn't know this!

I doubt anyone instinctively know when to use `._state`, `.state`,
`.raw_set_dataset_state` or `.set_dataset_state` and I think that was
part of what led to this bug.
@mvdbeek mvdbeek force-pushed the fix_failed_metadata_state branch from 864051a to 513ca74 Compare February 15, 2024 10:28
@mvdbeek mvdbeek merged commit 44487a5 into galaxyproject:release_23.2 Feb 15, 2024
43 of 46 checks passed
sa_session.add(self.dataset)
self.dataset.state = state

def set_metadata_succces_state(self):
Copy link
Member

Choose a reason for hiding this comment

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

Late to the party, but I guess that should have been set_metadata_success_state

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, fixed in #17481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/database Galaxy's database or data access layer kind/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants