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

Replace synchronized blocks with a ReentrantLock. The synchronized bl… #93

Closed
wants to merge 2 commits into from

Conversation

janickr
Copy link

@janickr janickr commented Jan 15, 2023

This is an addition to PR #91 of @bdeneuter:

The code inside the replaced synchronized blocks in ConnectionImpl and ServerPreparedQuery performed IO, the ones in NativeSession didn't, but were replaced because ServerPreparedQuery synchronized on NativeSession objects.

The synchronized blocks were removed and replaced by lock.lock() and lock.unlock(). This avoids that the carrier thread (OS thread) is pinned when running on virtual threads which were introduced as a preview feature in JDK 19.

https://openjdk.org/jeps/425
`There are two scenarios in which a virtual thread cannot be unmounted during blocking operations because it is pinned to its carrier:

When it executes code inside a synchronized block or method, or When it executes a native method or a foreign function.`

See also https://bugs.mysql.com/bug.php?id=109346

…ocks were removed and replaced by lock.lock() and lock.unlock(). This avoids that the carrier thread (OS thread) is pinned when running on virtual threads which were introduced as a preview feature in JDK 19.

The code inside the replaced synchronized blocks in ConnectionImpl and ServerPreparedQuery performed IO, the ones in NativeSession didn't, but were replaced because ServerPreparedQuery synchronized on NativeSession objects.

https://openjdk.org/jeps/425
`There are two scenarios in which a virtual thread cannot be unmounted during blocking operations because it is pinned to its carrier:

When it executes code inside a synchronized block or method, or
When it executes a native method or a foreign function.`

See also https://bugs.mysql.com/bug.php?id=109346
@mysql-oca-bot
Copy link

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@janickr
Copy link
Author

janickr commented Jan 19, 2023

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=109713 for updates.
Thanks

@apatrida
Copy link

apatrida commented Feb 5, 2023

Does this mean it now vanishes into a black hole? Or....

@fjssilva
Copy link
Contributor

Superseded by #95.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants