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

Why are methods not replayed on the PreparedStatement object in batch executor scenarios? #32468

Open
dunianbing opened this issue Aug 12, 2024 · 3 comments
Labels

Comments

@dunianbing
Copy link

Bug Report

In ShardingSpherePreparedStatement,settings of Statements will be recorded first and will be replayed on actual JDBC PreparedStatement after it is acquired. For exeample, in cacheStatements(...) method, replay() method will be called for method replay. As a result, in PreparedStatement scenarios, when executing executeQuery()、executeUpdate()、execute() methods, replay action will take effect.

But in batch executor scenarios, methods on statement object are not replyed. Related code is at initBatchPreparedStatementExecutor(...) method.
Why+are+methods+not+replayed+on+the+PreparedStatement+object+in+batch+executor+scenarios_.pdf

If there is no ShardingSphere-JDBC, such as MyBatis only, when executing executeBatch() method, settings of PreparedStatement object will take effect, involving setMaxFieldSize、setQueryTimeout, etc.

I would like to confirm whether this is by design or a flaw.

Which version of ShardingSphere did you use?

Shardingsphere 5.1.0 and 5.5.0

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

Settings of PreparedStatement object is valid in batch executor scenarios.

Actual behavior

Settings of PreparedStatement object is not valid in batch executor scenarios.

Reason analyze (If you can)

As above.

@dunianbing
Copy link
Author

@terrymanu Will there be any optimizations for this issue in the future?

@strongduanmu
Copy link
Member

@dunianbing The logic of Batch is more complex and has its own execution logic. In addition, did you encounter any problems? Did the execution report an error or the result was not as expected?

@dunianbing
Copy link
Author

@strongduanmu For example, regarding the statement's queryTimeout, the phenomenon is that SQL execution is not canceled after exceeding the set time, , and at the same time, the overall duration of the batch execution also increases.

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

No branches or pull requests

3 participants