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

Support for r2dbc-spi's Optional Interface 'LifeCycle' #64

Closed
jchrys opened this issue Apr 1, 2023 · 6 comments
Closed

Support for r2dbc-spi's Optional Interface 'LifeCycle' #64

jchrys opened this issue Apr 1, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@jchrys
Copy link
Collaborator

jchrys commented Apr 1, 2023

While implementing r2dbc-spi, the interface 'LifeCycle' is optional and not mandated by the specification.
However, we believe it is important to provide support for this interface as it can benefit minority use cases.
You can refer to this link for more information: https://r2dbc.io/spec/1.0.0.RELEASE/spec/html/#lifecycle.

@jchrys jchrys added enhancement New feature or request help wanted Extra attention is needed labels Apr 1, 2023
@svats0001
Copy link
Contributor

Hi @jchrys,

Do these interfaces need to be implemented anywhere or do they just need to be created? I think MySqlConnection has to implement Lifecycle. I don't think Wrapped needs to be implemented anywhere, it's up to the end user. Closeable might have to be implemented by MySqlConnectionFactory etc.

@jchrys
Copy link
Collaborator Author

jchrys commented Apr 17, 2023

You're absolutely right. There is no need to implement the Wrapped interface for MySqlConnection and MySqlConnectionFactory, as they are not wrappers. If, however, we come across a class that wraps an r2dbc-spi implementation, it would be advisable to implement Wrapped in that case.

@mirromutth
Copy link
Contributor

The MySqlConnection should to do nothing in postAllocate, only contains one job in preRelease, which is to rollback if it is in a transaction.

Which means postAllocate will return an empty Mono, and preRelease will be an alias as rollbackTransaction.

@mirromutth
Copy link
Contributor

mirromutth commented Dec 21, 2023

Hmmm, I noticed that the COM_RESET_CONNECTION command, which should be more suitable as preRelease, it resets almost all state, including temporary tables, transactions, etc.

@mirromutth
Copy link
Contributor

mirromutth commented Dec 21, 2023

Forget it, it turns out that COM_RESET_CONNECTION is not a good solution.

This command not being supported in 5.6.x and below, it will also cause all prepared statements to be cleared.

jchrys pushed a commit that referenced this issue Dec 21, 2023
Motivation:

Implement `Lifecycle` for `MySqlConnection`. See also #64 

Modification:

The `MySqlConnection`.

Result:

The `MySqlConnection` implements `Lifecycle` and will rollback in
`preRelease`.
jchrys pushed a commit that referenced this issue Dec 21, 2023
Motivation:

Implement `Lifecycle` for `MySqlConnection`. See also #64 and #171

Modification:

The `MySqlConnection`.

Result:

The `MySqlConnection` implements `Lifecycle` and will rollback in
`preRelease`.
@jchrys
Copy link
Collaborator Author

jchrys commented Dec 21, 2023

#171 #175

@jchrys jchrys closed this as completed Dec 21, 2023
@jchrys jchrys added this to the 1.0.6/0.9.7 milestone Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants