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

Allow configuring the prepared statement cache #227

Open
vijayakumarsuraj opened this issue Oct 29, 2021 · 4 comments · May be fixed by #229
Open

Allow configuring the prepared statement cache #227

vijayakumarsuraj opened this issue Oct 29, 2021 · 4 comments · May be fixed by #229
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement

Comments

@vijayakumarsuraj
Copy link

Running into an error where the first time a query executes (using the cursored execution mode) it works, but running it again fails because my SQL Server didn't recognize the cached prepared statement handle.

In my use-case, disabling the statement cache would be sufficient - my queries don't run very often. But in general, perhaps having discovery options that can control this cache, or exposing PreparedStatementCache as a type that applications can provide their own implementation of, would be suitable?

As a workaround I am reflectively updating the ConnectionOptions.preparedStatementCache field with my own "NoCache" implementation. But this is obviously not ideal.

I'm using 0.8.5.RELEASE, and running on Java 11. SQL Server version is 2012.

@mp911de mp911de added status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement labels Nov 8, 2021
@mp911de
Copy link
Member

mp911de commented Nov 8, 2021

Sounds like a good enhancement. Do you want to submit a pull request?

@vijayakumarsuraj
Copy link
Author

Yep. Can do.

vijayakumarsuraj added a commit to vijayakumarsuraj/r2dbc-mssql that referenced this issue Nov 11, 2021
- Make PreparedStatementCache (and implementations) public
- Expose preparedStatementCache discovery option. Similar to what r2dbc-postgresql exposes: -1 = indefinite cache, 0 = no cache, n = lru cache with max size n.
- Add LRUPreparedStatementCache and NoPreparedStatementCache implementations. 

[r2dbc#227]

Signed-off-by: Suraj Vijayakumar <vijayakumar.suraj@gmail.com>
vijayakumarsuraj added a commit to vijayakumarsuraj/r2dbc-mssql that referenced this issue Nov 11, 2021
- Make PreparedStatementCache (and implementations) public
- Expose preparedStatementCache discovery option. Similar to what r2dbc-postgresql exposes: -1 = indefinite cache, 0 = no cache, n = lru cache with max size n.
- Add LRUPreparedStatementCache and NoPreparedStatementCache implementations. 

[r2dbc#227]

Signed-off-by: Suraj Vijayakumar <vijayakumar.suraj@gmail.com>
vijayakumarsuraj added a commit to vijayakumarsuraj/r2dbc-mssql that referenced this issue Nov 11, 2021
- Make PreparedStatementCache public
- Expose preparedStatementCache discovery option. Similar to what r2dbc-postgresql exposes: -1 = indefinite cache, 0 = no cache, n = lru cache with max size n.
- Add LRUPreparedStatementCache and NoPreparedStatementCache implementations. 

[r2dbc#227]

Signed-off-by: Suraj Vijayakumar <vijayakumar.suraj@gmail.com>
@vijayakumarsuraj vijayakumarsuraj linked a pull request Nov 11, 2021 that will close this issue
4 tasks
@vijayakumarsuraj
Copy link
Author

@mp911de , created #229 for this.

@mp911de mp911de linked a pull request Nov 12, 2021 that will close this issue
4 tasks
@stephanpelikan
Copy link

I see errors Could not find prepared statement with handle 1073741825 when repeating queries fast.

Actually not really fast, I do it by clicking a button repeatingly. If I click once per second, everything is fine. If I click faster I get the error sometimes. Sometimes it also seems to stuck and I get the error for every attempt.

In one of my applications I enabled the R2DBC pool configuration what solved the problems. In another of my application the enabling the pool didn't change the behavior at all.

What do you think. Can this PR solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants