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

Drop old galaxy_session records #19872

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

jdavcs
Copy link
Member

@jdavcs jdavcs commented Mar 21, 2025

Ref #13992

Is 1 month a safe cut off for deleting old sessions? If so, main has 173M session records that are more than 2 months old (checked against updated_time; if checked against last_action value, then 151M).

This introduces some minor duplication (see the history pruning script, as well as admin documentation). I'll refactor as needed when adding more such scripts (as per #13992).

A note on prev_session_id:
The galaxy_session.prev_session_id field should be defined as a self-referencing foreign key, but it is not. Instead, it's an integer field which allows null values. Adding a foreign key constraint is trivial; however, the migration process would have to include fixing existing data by setting to null any existing values that do not correspond to an existing galaxy_session record. For databases like main, which contains 173M galaxy_session records, this process requires special handling, and the migration may take a long time. In this case it seems to be not worth the effort.

UPDATE: we do need the previous session id to be available; however, it is not accessed from the code base and, from a practical standpoint, a foreign key constraint is not needed.

To do:

  • Check code base for potential problems when session record has been deleted
  • Add cascading for: deleting GalaxySessionToHistoryAssociation records, setting to null references on job, event, user_action, galaxy_session (self ref) (model + db migrations)
  • Add script to delete session records (also handle references to prev session in galaxy_session table, which is not a foreign key)

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. Upgrade database to enable ondelete behavior
    2. Check galaxy_session records in your current local database
    3. Run script with some cutoff date, verify database that records have been deleted
    4. Run script without setting a date, verify database that records older than one month have been deleted.

License

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

@jdavcs jdavcs added kind/feature area/database Galaxy's database or data access layer labels Mar 21, 2025
@jdavcs jdavcs force-pushed the dev_13922_session branch from b536082 to 39beaf7 Compare March 25, 2025 23:57
@jdavcs jdavcs marked this pull request as ready for review March 25, 2025 23:57
@jdavcs jdavcs force-pushed the dev_13922_session branch from 39beaf7 to df126a2 Compare March 26, 2025 00:07
@jdavcs jdavcs changed the title [WIP] Drop old galaxy_session records Drop old galaxy_session records Mar 26, 2025
@github-actions github-actions bot added this to the 25.0 milestone Mar 26, 2025
@jdavcs jdavcs requested a review from a team March 26, 2025 00:09
@jdavcs
Copy link
Member Author

jdavcs commented Mar 26, 2025

test failures unrelated.

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/feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant