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

[24.1] Fix named cursor is not valid anymore #18825

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

mvdbeek
Copy link
Member

@mvdbeek mvdbeek commented Sep 17, 2024

Fixes
#18782 / https://sentry.galaxyproject.org/share/issue/dca23c8d10e743509648cf6092a1dc15/:

Message
Error closing cursor
Stack Trace

Newest

ProgrammingError: named cursor isn't valid anymore
  File "sqlalchemy/engine/cursor.py", line 1255, in fetchmany
    new = dbapi_cursor.fetchmany(size - lb)
ProgrammingError: named cursor isn't valid anymore
  File "sqlalchemy/engine/base.py", line 2213, in _safe_close_cursor
    cursor.close()

(Please replace this header with a description of your pull request. Please include BOTH what you did and why you made the changes. The "why" may simply be citing a relevant Galaxy issue.)
(If fixing a bug, please add any relevant error or traceback)
(For UI components, it is recommended to include screenshots or screencasts)

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.

@mvdbeek mvdbeek added kind/bug area/database Galaxy's database or data access layer labels Sep 17, 2024
@github-actions github-actions bot added this to the 24.1 milestone Sep 17, 2024
lib/galaxy/managers/jobs.py Outdated Show resolved Hide resolved
Fixes
galaxyproject#18782 / https://sentry.galaxyproject.org/share/issue/dca23c8d10e743509648cf6092a1dc15/:
```
Message
Error closing cursor
Stack Trace

Newest

ProgrammingError: named cursor isn't valid anymore
  File "sqlalchemy/engine/cursor.py", line 1255, in fetchmany
    new = dbapi_cursor.fetchmany(size - lb)
ProgrammingError: named cursor isn't valid anymore
  File "sqlalchemy/engine/base.py", line 2213, in _safe_close_cursor
    cursor.close()
```
@@ -1119,7 +1119,7 @@ def get_jobs_to_check_at_startup(session: galaxy_scoped_session, track_jobs_in_d
# Filter out the jobs of inactive users.
stmt = stmt.outerjoin(User).filter(or_((Job.user_id == null()), (User.active == true())))

return session.scalars(stmt)
return session.scalars(stmt).all()
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also add type annotation for the function return value?

Copy link
Member Author

@mvdbeek mvdbeek Sep 17, 2024

Choose a reason for hiding this comment

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

I really do not like these overly verbose annotations. What is the advantage over the inferred type ?
Screenshot 2024-09-17 at 15 29 00
The advantage of not doing it is that any change in the sqlalchemy mechanics gets propagated to us.

Copy link
Member

Choose a reason for hiding this comment

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

It would help with code refactorings and when reviewing e.g. on GitHub, but it's fine if you prefer not to.

@mvdbeek mvdbeek merged commit d17d742 into galaxyproject:release_24.1 Sep 17, 2024
47 of 49 checks passed
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.

3 participants