Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

set_rollback should only rollback initialized connections#9599

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jdetaeye wants to merge1 commit intoencode:main
base:main
Choose a base branch
Loading
fromjdetaeye:master

Conversation

@jdetaeye
Copy link

The exception handler call "connections.all()". This creates a database connection to all defined databases. As a small optimization you can use "connections.all(initialized_only=True)" to rollback only the database to which the current thread has open connections.

(My application can have many databases defined, and this loop is identified as a source of many idle database connections)

Note: Before submitting a code change, please review ourcontributing guidelines.

Description

Please describe your pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. When linking to an issue, please userefs #... in the description of the pull request.

The exception handler call "connections.all()". This creates a database connection to all defined databases. As a small optimization you can use "connections.all(initialized_only=True)" to rollback only the database to which the current thread has open connections.(My application can have many databases defined, and this loop is identified as a source of many idle database connections)
Copy link
Collaborator

@auvipyauvipy left a comment

Choose a reason for hiding this comment

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

is it possible to add tests to avoid regression?

@jdetaeye
Copy link
Author

@auvipy I just looked into updating

deftest_class_based_view_exception_handler(self):
with such a test. I failed creating a test case demonstrating the fix (maybe related to the in memory sqlite database used by the test?). Sorry, I won't be able to provide a test.

@stale
Copy link

stalebot commentedApr 26, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelApr 26, 2025
@auvipyauvipy requested a review fromCopilotApril 27, 2025 08:43
Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request optimizes the rollback process by limiting the rollback to initialized database connections only.

  • Updated the set_rollback function to use the "initialized_only" flag
  • Reduces unnecessary database connection instantiation during exception handling

@auvipyauvipy requested a review froma teamApril 27, 2025 08:44
@stalestalebot removed the stale labelApr 27, 2025
Copy link
Collaborator

@peterthomassenpeterthomassen left a comment

Choose a reason for hiding this comment

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

This looks very reasonable, and I've followed the flow into what Django does when this is called, and it lgtm.

I've also verified that this issupported by all Django releases we rely on. I guess we didn't have this initially because it was only introduced in Django 4.1.

@stale
Copy link

stalebot commentedJul 19, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelJul 19, 2025
@stalestalebot closed thisOct 18, 2025
@auvipyauvipy reopened thisOct 18, 2025
@stalestalebot removed the stale labelOct 18, 2025
@browniebrokebrowniebroke added this to the3.17 milestoneOct 20, 2025
@browniebrokebrowniebroke changed the titleset_roll_back should only rollback initialized connectionsset_rollback should only rollback initialized connectionsOct 20, 2025
@browniebroke
Copy link
Member

How does it work with that other PR?

Are they related, complementary?

@auvipy
Copy link
Collaborator

I think we should wait a bit to decide on this two.

browniebroke reacted with thumbs up emoji

@browniebrokebrowniebroke removed this from the3.17 milestoneOct 30, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@auvipyauvipyauvipy left review comments

Copilot code reviewCopilotCopilot left review comments

@browniebrokebrowniebrokebrowniebroke approved these changes

@peterthomassenpeterthomassenpeterthomassen approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@jdetaeye@browniebroke@auvipy@peterthomassen

[8]ページ先頭

©2009-2025 Movatter.jp