Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Unit tests hang: java.sql.SQLException: Data source is closed #397

Closed
ghost opened this issue Apr 11, 2019 · 2 comments
Closed

Unit tests hang: java.sql.SQLException: Data source is closed #397

ghost opened this issue Apr 11, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 11, 2019

  • fresh checkout of tag alfresco-repository-7.43
  • empty PostgreSQL database created
$ mvn clean test \
  -Ddb.driver=org.postgresql.Driver \
  -Ddb.name=alfresco-6 \
  -Ddb.url=jdbc:postgresql:alfresco-6 \
  -Ddb.username=lutz \
  -Ddb.password=lutz

Tail on target/surefire-reports/org.alfresco.RepositoryStartStopTest-output.txt:

2019-04-11 11:36:20,802  DEBUG [repo.transaction.RetryingTransactionHelper] [JobLockService1]
Transaction commit failed:
   Thread: JobLockService1
   Txn:    UserTransaction[object=org.alfresco.util.transaction.SpringAwareUserTransaction@3cd249ab, status=6]
   Iteration: 4
   Exception follows:
 org.alfresco.util.transaction.ConnectionPoolException: 03110086 The DB connection pool is depleted.
        at org.alfresco.util.transaction.SpringAwareUserTransaction.begin(SpringAwareUserTransaction.java:418)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:439)
        at org.alfresco.repo.lock.JobLockServiceImpl.releaseLockVerify(JobLockServiceImpl.java:477)
        at org.alfresco.repo.lock.JobLockServiceImpl$2.run(JobLockServiceImpl.java:385)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: Data source is closed
        at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:305)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:378)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:474)
        at org.alfresco.util.transaction.SpringAwareUserTransaction.begin(SpringAwareUserTransaction.java:413)
        ... 10 more
Caused by: java.sql.SQLException: Data source is closed
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1362)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
        at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:262)
        ... 13 more

The unit test uses 11 databae connections:

lutz@localhost:alfresco-6> select usename, application_name
 from pg_stat_activity
 where datname = 'alfresco-6';
+-----------+------------------------+
| usename   | application_name       |
|-----------+------------------------|
| lutz      | pgcli                  |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
| lutz      | PostgreSQL JDBC Driver |
+-----------+------------------------+
SELECT 12

What is missing?

@killerboot
Copy link
Contributor

There was a fix to this test in 28e4df5 which may affect your results.
The tests are always run in suits like AllUnitTestsSuite, AppContext01TestSuite and etc. See https://github.com/Alfresco/alfresco-repository/blob/master/.travis.yml .
Unfortunately the tests will fail if all of them will be run in one batch due to test data or config cleanup issues.

@killerboot
Copy link
Contributor

Please reopen if it is still an issue.

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

No branches or pull requests

1 participant