Skip to content

Revise JdbcChatMemoryRepository tests #3200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented May 16, 2025

  1. Fix failed JdbcChatMemoryRepositoryPostgresqlIT tests due to connection leakage:
org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection

	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:84)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:653)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:723)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:754)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:767)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:820)
	at org.springframework.jdbc.core.JdbcTemplate.queryForList(JdbcTemplate.java:954)
	at org.springframework.ai.chat.memory.repository.jdbc.AbstractJdbcChatMemoryRepositoryIT.saveMessagesMultipleMessages(AbstractJdbcChatMemoryRepositoryIT.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30001ms (total=10, active=10, idle=0, waiting=0)
	at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:686)
	at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:179)
	at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:144)
	at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:127)
	at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)
	... 10 more
  1. Remove unnecessary tests, correctChatMemoryRepositoryInstance() do nothing, repositoryWithExplicitTransactionManager() actually doesn't test explicit transaction manager

@quaff
Copy link
Contributor Author

quaff commented May 16, 2025

@sunyuhan1998 I notice some test code committed by you, could you take a look?

Before this commit, the underlying `JdbcTemplate` is created like `new JdbcTemplate(providedJdbcTemplate.getDataSource())`, it means that settings on provided `JdbcTemplate` will lose.

Signed-off-by: Yanming Zhou <[email protected]>
@markpollack
Copy link
Member

Hi. I did not have failures in JdbcChatMemoryRepositoryPostgresqlITcan you explain more what you observed.

@markpollack markpollack self-assigned this May 16, 2025
@markpollack markpollack added this to the 1.0.0 milestone May 16, 2025
@markpollack
Copy link
Member

Thanks so much. 🍺

merged in b83a162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants