feat(tidb-stmt-cache): add Pulsar partitioned-topic replay scenario#140
Open
khareyash05 wants to merge 2 commits into
Open
feat(tidb-stmt-cache): add Pulsar partitioned-topic replay scenario#140khareyash05 wants to merge 2 commits into
khareyash05 wants to merge 2 commits into
Conversation
Extends the existing TiDB orphan-COM_STMT_EXECUTE sample with an HTTP endpoint that exercises Apache Pulsar's RoundRobinPartition routing — the producer-side behaviour that triggers keploy's partition-suffix replay mismatch (keploy/enterprise#2064). The bean shape, JDBC parameters and JPA settings replicate the Flipkart Global-Shipment-Master service's production config so a recording captured against this sample produces mocks structurally identical to the customer's: * HikariCP autoCommit=false paired with spring.jpa.properties.hibernate.connection.provider_disables_autocommit=true * JDBC URL: useServerPrepStmts=true&cachePrepStmts=true &prepStmtCacheSize=500&prepStmtCacheSqlLimit=2048 * Hibernate MySQLDialect (TiDB is wire-compatible on :4000), open-in-view=false * Pulsar producer with MessageRoutingMode.RoundRobinPartition against an 8-partition topic pre-created by the docker-compose pulsar-init container New endpoint: POST /events/patch — JPA-saves an Event row through TiDB then synchronously publishes the payload to the partitioned topic; mirrors the Flipkart endpoint shape exactly so the customer's mocks.yaml can be replayed against this sample. Existing /api/kv/* endpoints (orphan-EXECUTE scenario) are unchanged. Additions: * EventEntity / EventRepository: JPA persistence, Hibernate auto-DDL creates the `events` table. * PulsarConfig: PulsarClient + Producer<byte[]> beans. * EventsController: @transactional POST /events/patch. * docker-compose: Apache Pulsar 4.0.3 standalone + one-shot pulsar-init that creates the partitioned topic. * Dockerfile: two-stage Maven -> JRE 17 build. * k8s/ manifests: namespace, TiDB Deployment+Service, Pulsar Deployment+Service+Job, app Deployment+Service with keploy.io/record-session=true for the static webhook. * README: walkthroughs for the local docker-compose smoke path and the in-cluster k8s-proxy auto-replay path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The original sample documentation and inline comments named the internal service, recording, message broker tenant, and entity-id format the regression was first reported against. None of those identifiers are needed to explain the bug — the failure mode is a generic property of RoundRobinPartition routing across record/replay sessions. Replace them with neutral phrasing. Behavioural changes: none. Only docs, comments, and the example curl payloads are touched. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
248f082 to
ff6c672
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tidb-stmt-cachewith a Pulsar producer + JPA-drivenPOST /events/patchendpoint that exercises Apache Pulsar's defaultRoundRobinPartitionrouting — the producer-side behaviour that surfaces the partition-suffix replay mismatch fixed in keploy/enterprise#2064./api/kv/*orphan-EXECUTE endpoints are untouched.What's new
pom.xmlspring-boot-starter-data-jpa+pulsar-client:3.1.1application.propertiesautoCommit=false, JDBCprepStmtCacheSize=500&prepStmtCacheSqlLimit=2048, JPAprovider_disables_autocommit=true, MySQLDialect,open-in-view=false, Pulsar broker/topic/partition-countDataSourceConfig.javaEventEntity.java/EventRepository.javaeventstablePulsarConfig.javaPulsarClient+Producer<byte[]>withMessageRoutingMode.RoundRobinPartitionEventsController.java@Transactional POST /events/patch— JPA save + sync Pulsar senddocker-compose.ymlDockerfilek8s/keploy.io/record-session=truelabelREADME.mdWhy RoundRobinPartition specifically
Pulsar's Java client default routing picks a random starting partition per producer instance. Across record/replay sessions the same producer publishing the same payload routes to a different partition number, so a recording captured on
…events-partition-Ncannot serve a live SEND to…events-partition-M. This is the smallest reliable repro — pinning routing (SinglePartition + fixed key) would mask the bug.Test plan
mvn -DskipTests package— 8 sources compile, fat jar builds.docker compose up -dboots TiDB, Pulsar (with 8 partitions), and the app cleanly.curl POST /events/patchreturns{"message":"Event patched"}with HTTP 200 against the local stack (docker composemode, no agent).k8s/manifests: TiDB / Pulsar / app all reachReady;POST /events/patchreturns 200 against the in-cluster Service.keploy-agentsidecar when thekeploy.io/record-sessionlabel is present.🤖 Generated with Claude Code