Skip to content

Conversation

@littleniannian
Copy link

@littleniannian littleniannian commented Nov 18, 2025

/**
* 记录 userId + dataSourceId 的会话数 Key格式: userId:dataSourceId
*/
private Map<String, AtomicInteger> userId2DataSourceId2SessionCountMap = new ConcurrentHashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里记录的为什么是会话数,预期是连接数?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里暂时是会话层面的连接,再目前一个会话对应一个连接的情况下是正确的。

/**
* Connection count manager for tracking database connections by url+username
*
* @author yh263208
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

log.info("Incremented connection count, key={}", this.connectionKey);
Connection connection = newConnectionFromDriver(getUsername(), getPassword());
// Generate connection key and check/increment connection count
this.connectionKey = ConnectionCountManager.generateKey(getUrl(), getUsername());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的url指的是啥,username是数据库连接用户名称吗

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url是数据库连接串,username是数据库连接用户名

@littleniannian
Copy link
Author

  • 目前用户维度的数据源指标写在了Session的维度中
  • 数据源维度的指标写在了SingleConnectionDataSource的维度中
  • 其实都可以写在SingleConnectionDataSource维度中,这是一个可以优化的点

@LordofAvernus LordofAvernus merged commit 25fd00e into actiontech:dev/4.3.4 Nov 21, 2025
@littleniannian littleniannian deleted the opt_connection branch November 21, 2025 09:57
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