Skip to content

Conversation

Oscarcheng0312
Copy link
Contributor

@Oscarcheng0312 Oscarcheng0312 commented Jul 25, 2025

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

This PR introduces a complete SQL monitoring system and a connection pool abstraction with a concrete implementation, forming the foundation of the connection-pool in Seata.

  1. SQL‑event collector (package org.apache.seata.common.monitor)
    • SqlExecutionEntry: immutable model of a single SQL execution event (sql, executionTimeMillis, holdTimeMillis, timestamp).
    • SqlMonitor: singleton collector that
      • records all SQL events (up to maxAllRecords)
      • records slow SQL events (execMs > slowThreshold) up to maxSlowEntries
      • exposes getAllRecords(), getSlowSqlList(), clearOldRecords(), resetForTest().
  2. ConnectionPool (package org.apache.seata.common.pool)
    • ConnectionPoolConfig & ConnectionPoolMetrics: plain‐old‐Java objects representing connection‐pool metrics and config.
    • PoolManager: interface defining methods getConfig(), getMetrics(), updateConfig().
    • PoolManagerRegistry: simple lookup/factory returning a PoolManager instance by DataSource type.
  3. Concrete Connection Pool Implementation
    • Adds actual implementation of PoolManager for supported pool types (e.g., Druid/Hikari) using reflection.
  4. Unit Tests
    • SqlMonitorTest: Covers core monitor behaviors (recording, slow query detection, eviction, clear/reset)
    • Connection Pool Tests: Verifies the correctness of PoolManager implementations, metric reporting, and configuration updating.

Ⅱ. Does this pull request fix one issue?

No — this is a new feature for the common module and rm-datasource module, including features about SQL monitor for Druid, connection‐pool metrics config, and the implementation of the connection-pool.

Ⅲ. Why don't you add test cases (unit test/integration test)?

Unit tests are included for all core behaviors of SqlMonitor.
Connection pool implementation (config, metrics, update)

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@Oscarcheng0312 Oscarcheng0312 changed the title feature: add SqlExecutionEntry, SqlMonitor and its tests feature: add SqlExecutionEntry, SqlMonitor and connection pool abstraction interfaces Jul 26, 2025
@Oscarcheng0312 Oscarcheng0312 marked this pull request as ready for review July 26, 2025 09:24
@Oscarcheng0312 Oscarcheng0312 changed the title feature: add SqlExecutionEntry, SqlMonitor and connection pool abstraction interfaces feature: add SQL monitoring and connection pool abstraction with implementation and tests Jul 29, 2025
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.

1 participant