Skip to content

feat(spring-mysql-redis): add endpoint to trigger COM_STMT_RESET#136

Merged
gouravkrosx merged 1 commit into
mainfrom
feat/mysql-stmt-reset-endpoint
May 27, 2026
Merged

feat(spring-mysql-redis): add endpoint to trigger COM_STMT_RESET#136
gouravkrosx merged 1 commit into
mainfrom
feat/mysql-stmt-reset-endpoint

Conversation

@khareyash05
Copy link
Copy Markdown
Member

Summary

  • Adds GET /api/todos/stmt-reset/{id}/{n} to spring-mysql-redis that re-executes a server-side prepared statement n times on the same connection.
  • Updates the JDBC URL with useServerPrepStmts=true&cachePrepStmts=true&useCursorFetch=true so MySQL Connector/J 8.x emits COM_STMT_RESET between re-executions.
  • Lets us exercise the synthetic-OK fallback path added in fix(mysql/replay): synthesize OK for unmocked COM_STMT_RESET keploy#4217 during keploy record/replay.

Why

keploy/keploy#4217 fixes the case where an unmocked COM_STMT_RESET would cause keploy to close the TCP connection, surfacing as CJCommunicationsException / Socket is closed. None of the existing sample endpoints reliably trigger COM_STMT_RESET, so we need a dedicated path that forces server-side cursor reuse.

How to test

cd spring-mysql-redis
docker run --name mysql-todo -e MYSQL_DATABASE=todoapp \
  -e MYSQL_USER=yourusername -e MYSQL_PASSWORD=yourpassword \
  -e MYSQL_ROOT_PASSWORD=rootpassword -p 3306:3306 -d mysql:8
mvn -DskipTests package

# record (local keploy build with PR #4217)
keploy record -c "java -jar target/todo-spring-app-1.0-SNAPSHOT.jar"

# in another shell
curl -X POST http://localhost:8080/api/todos -H 'Content-Type: application/json' \
  -d '{"title":"t1","description":"d1","completed":false}'
curl http://localhost:8080/api/todos/stmt-reset/1/5

# replay
keploy test -c "java -jar target/todo-spring-app-1.0-SNAPSHOT.jar" --delay 20

Test plan

  • mvn package succeeds (note: pre-existing Lombok/@Data config in pom.xml may need annotation-processor wiring on Java 21 — unrelated to this PR).
  • keploy record against the endpoint captures the new traffic.
  • keploy test replay logs show the COM_STMT_RESET debug line (stmt id) from fix(mysql/replay): synthesize OK for unmocked COM_STMT_RESET keploy#4217.
  • Replay completes without CJCommunicationsException / SQLSTATE 08S01 / Socket is closed in the app logs.

🤖 Generated with Claude Code

Adds GET /api/todos/stmt-reset/{id}/{n} which re-executes a server-side
prepared statement n times on the same connection. Combined with the new
JDBC URL flags (useServerPrepStmts, cachePrepStmts, useCursorFetch),
MySQL Connector/J 8.x emits COM_STMT_RESET between re-executions, which
exercises the synthetic-OK fallback path added in keploy/keploy#4217 so
record/replay can be validated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gouravkrosx gouravkrosx merged commit 080077f into main May 27, 2026
2 checks passed
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.

2 participants