Skip to content

fix(mysql-session): commit writes when auto-commit is disabled#1111

Open
Alexxigang wants to merge 5 commits intoagentscope-ai:mainfrom
Alexxigang:fix/mysql-session-write-transactions
Open

fix(mysql-session): commit writes when auto-commit is disabled#1111
Alexxigang wants to merge 5 commits intoagentscope-ai:mainfrom
Alexxigang:fix/mysql-session-write-transactions

Conversation

@Alexxigang
Copy link
Copy Markdown
Contributor

Summary

  • make MysqlSession write paths use consistent transactional behavior when connections start with autoCommit=false
  • preserve the original connection auto-commit state instead of forcing it back to true
  • add unit and H2 E2E regressions covering single-state writes, list append writes, and full-rewrite behavior

Why this fix

MysqlSession.save(...) previously committed the full-rewrite list path manually, but left append writes and other write paths relying on the connection's default auto-commit behavior. When a datasource returns connections with autoCommit=false, those writes can be lost. The previous full-rewrite path also mutated the connection state by always restoring autoCommit=true.

This change routes write operations through a shared transactional helper so the module commits its own writes consistently and only restores the connection state when it actually changed it.

Closes #1087.

Validation

  • mvn -pl agentscope-extensions/agentscope-extensions-session-mysql -am -DskipTests test-compile
  • mvn -pl agentscope-extensions/agentscope-extensions-session-mysql -am "-Dtest=MysqlSessionTest,MysqlSessionE2ETest" "-Dsurefire.failIfNoSpecifiedTests=false" test

@Alexxigang
Copy link
Copy Markdown
Contributor Author

Friendly ping on this PR when maintainers have time. The fix and validation are ready on my side, and I'm happy to make any follow-up adjustments if review feedback comes in. Thanks!

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.

[Bug]: MysqlSession Can Not Save New Sessions when auto-commit=false

1 participant