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 with ReentrantLock #95

Closed
wants to merge 1 commit into from

Conversation

bdeneuter
Copy link

@bdeneuter bdeneuter commented Mar 24, 2023

Replace synchronized blocks with a ReentrantLock. 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 JEP that is being prepared for JDK 21 still contains the limitation:
https://openjdk.org/jeps/8303683

`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.`

This PR makes the following PRs obsolete as it replaces them:
#91
#93

Replace connectionMutex and synchronized blocks with a ReentrantLock. 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.

The JEP that is being prepared for JDK 21:
https://openjdk.org/jeps/8303683

`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.`
@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

@bdeneuter
Copy link
Author

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=110512 for updates.
Thanks

@masoudparvari
Copy link

Is there any plan to get this merged ?

@fjssilva
Copy link
Contributor

Hi @masoudparvari, we do have plans to analyze it thoroughly and may consider merging it. That work hasn't been completed yet. It's a significant change and we need to be very careful to avoid causing damage to others. I hope you understand. Thanks,

@zzhujing
Copy link

Hi @masoudparvari, we do have plans to analyze it thoroughly and may consider merging it. That work hasn't been completed yet. It's a significant change and we need to be very careful to avoid causing damage to others. I hope you understand. Thanks,

how long ? i want to use virtual threads with mysql ..

@He-Pin
Copy link

He-Pin commented Apr 26, 2024

Why this was closed :(

image

@fjssilva
Copy link
Contributor

It's how Oracle MySQL's contribution process works. Follow up in the bug report mentioned in the last post by @mysql-oca-bot.

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

Successfully merging this pull request may close these issues.

6 participants