zonkyio / embedded-database-spring-test

A library for creating isolated embedded databases for Spring-powered integration tests.
Apache License 2.0
399 stars 37 forks source link

Flyway migration in multitenant application #261

Closed jomatt closed 1 month ago

jomatt commented 6 months ago

My integration tests often fail with the error source database "uqlipbuiagmk" is being accessed by other users. The issue is not easy to reproduce since it happens non-deterministically. In between the two log blocks below (separated with [...]), all tests finish successfully.

Any ideas what could be the problem here?

2024-02-29 13:22:49.475                  INFO 75 --- [           main] c.a.zonkytest.core.config.CacheConfigIT  : Starting CacheConfigIT using Java 21.0.2 with PID 75 (started by root in /builds/zonkytest-ac/zonkytest/zonkytest)
2024-02-29 13:22:49.475                  INFO 75 --- [           main] c.a.zonkytest.core.config.CacheConfigIT  : The following 1 profile is active: "test"
2024-02-29 13:22:49.893                  INFO 75 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-02-29 13:22:49.958                  INFO 75 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 64 ms. Found 14 JPA repository interfaces.
2024-02-29 13:22:50.046                  INFO 75 --- [           main] EmbeddedDatabaseContextCustomizerFactory : Replacing 'dataSource' DataSource bean with embedded version
2024-02-29 13:22:50.050                  INFO 75 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=a1c00890-df07-3275-a59c-adb20e773f36
2024-02-29 13:22:50.113                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration' of type [org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:22:50.114                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:22:50.115                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerClientsDefaultsMappingsProvider' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration$$Lambda$868/0x0000000801225810] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:22:50.116                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'defaultsBindHandlerAdvisor' of type [org.springframework.cloud.commons.config.DefaultsBindHandlerAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:22:50.118                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration' of type [org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:22:50.119                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'stringOrNumberMigrationVersionConverter' of type [org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$StringOrNumberToMigrationVersionConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:22:50.124                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.sleuth.jdbc-org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.TraceJdbcProperties' of type [org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.TraceJdbcProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:22:50.202                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'io.zonky.test.db.config.EmbeddedDatabaseAutoConfiguration' of type [io.zonky.test.db.config.EmbeddedDatabaseAutoConfiguration$$EnhancerBySpringCGLIB$$3420a2ee] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:22:50.296                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:50.296                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:50.296                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:50.306                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:50.306 UTC [27] LOG:  TimescaleDB background worker limit of 8 exceeded
2024-02-29 13:22:50.306                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:50.306 UTC [27] HINT:  Consider increasing timescaledb.max_background_workers.
2024-02-29 13:22:50.307                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:50.306 UTC [177] LOG:  terminating TimescaleDB job scheduler due to administrator command
2024-02-29 13:22:50.307                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:50.306 UTC [177] FATAL:  terminating connection due to administrator command
2024-02-29 13:22:50.310                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:50.309 UTC [1] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 177) exited with exit code 1
2024-02-29 13:22:50.313                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:50.313 UTC [1816] LOG:  terminating TimescaleDB scheduler entrypoint due to administrator command
2024-02-29 13:22:50.314                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:50.313 UTC [1816] FATAL:  terminating connection due to administrator command
2024-02-29 13:22:50.314                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:50.314 UTC [1] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 1816) exited with exit code 1
2024-02-29 13:22:50.481                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:50.490                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 16 migrations (execution time 00:00.004s)
2024-02-29 13:22:50.493                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "public": 2023.03.26.1728
2024-02-29 13:22:50.493                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "public" may not be reproducible.
2024-02-29 13:22:50.494                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "public" is up to date. No migration necessary.
2024-02-29 13:22:50.562                  INFO 75 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2024-02-29 13:22:50.605                  INFO 75 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2024-02-29 13:22:50.815                  INFO 75 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2024-02-29 13:22:50.815                  INFO 75 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2024-02-29 13:22:52.501                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:52.501                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:52.501                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:52.507                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:52.515                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 11 migrations (execution time 00:00.004s)
2024-02-29 13:22:52.518                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "allowed-all": 2023.12.05.1221
2024-02-29 13:22:52.518                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "allowed-all" may not be reproducible.
2024-02-29 13:22:52.519                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "allowed-all" is up to date. No migration necessary.
2024-02-29 13:22:52.521                  INFO 75 --- [           main] c.a.zonkytest.core.config.FlywayConfig   : Flyway migration progress: 1/8
2024-02-29 13:22:52.522                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:52.522                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:52.522                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:52.528                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:52.535                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 11 migrations (execution time 00:00.003s)
2024-02-29 13:22:52.537                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "allowed-child": 2023.12.05.1221
2024-02-29 13:22:52.537                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "allowed-child" may not be reproducible.
2024-02-29 13:22:52.542                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "allowed-child" is up to date. No migration necessary.
2024-02-29 13:22:52.546                  INFO 75 --- [           main] c.a.zonkytest.core.config.FlywayConfig   : Flyway migration progress: 2/8
2024-02-29 13:22:52.548                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:52.548                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:52.548                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:52.562                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:52.583                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 108 migrations (execution time 00:00.017s)
2024-02-29 13:22:52.586                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "allowed-grandchild": 2024.01.24.1212
2024-02-29 13:22:52.586                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "allowed-grandchild" may not be reproducible.
2024-02-29 13:22:52.587                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "allowed-grandchild" is up to date. No migration necessary.
2024-02-29 13:22:52.588                  INFO 75 --- [           main] c.a.zonkytest.core.config.FlywayConfig   : Flyway migration progress: 3/8
2024-02-29 13:22:52.589                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:52.589                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:52.590                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:52.597                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:52.617                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 108 migrations (execution time 00:00.016s)
2024-02-29 13:22:52.620                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "zonkytest": 2024.01.24.1212
2024-02-29 13:22:52.620                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "zonkytest" may not be reproducible.
2024-02-29 13:22:52.623                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "zonkytest" is up to date. No migration necessary.
2024-02-29 13:22:52.624                  INFO 75 --- [           main] c.a.zonkytest.core.config.FlywayConfig   : Flyway migration progress: 4/8
2024-02-29 13:22:52.627                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:52.627                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:52.627                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:52.635                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:52.645                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 11 migrations (execution time 00:00.005s)
2024-02-29 13:22:52.648                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "restricted": 2023.12.05.1221
2024-02-29 13:22:52.648                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "restricted" may not be reproducible.
2024-02-29 13:22:52.649                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "restricted" is up to date. No migration necessary.
2024-02-29 13:22:52.650                  INFO 75 --- [           main] c.a.zonkytest.core.config.FlywayConfig   : Flyway migration progress: 5/8
2024-02-29 13:22:52.656                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:52.656                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:52.656                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:52.663                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:52.670                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 11 migrations (execution time 00:00.003s)
2024-02-29 13:22:52.672                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "restricted-child-1": 2023.12.05.1221
2024-02-29 13:22:52.672                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "restricted-child-1" may not be reproducible.
2024-02-29 13:22:52.673                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "restricted-child-1" is up to date. No migration necessary.
2024-02-29 13:22:52.674                  INFO 75 --- [           main] c.a.zonkytest.core.config.FlywayConfig   : Flyway migration progress: 6/8
2024-02-29 13:22:52.677                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:52.677                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:52.677                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:52.690                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:52.725                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 108 migrations (execution time 00:00.029s)
2024-02-29 13:22:52.728                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "restricted-child-2": 2024.01.24.1212
2024-02-29 13:22:52.728                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "restricted-child-2" may not be reproducible.
2024-02-29 13:22:52.730                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "restricted-child-2" is up to date. No migration necessary.
2024-02-29 13:22:52.731                  INFO 75 --- [           main] c.a.zonkytest.core.config.FlywayConfig   : Flyway migration progress: 7/8
2024-02-29 13:22:52.732                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:22:52.732                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:22:52.732                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:22:52.746                  INFO 75 --- [           main] o.f.c.i.database.base.BaseDatabaseType   : Database: jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq (PostgreSQL 12.3)
2024-02-29 13:22:52.776                  INFO 75 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 108 migrations (execution time 00:00.024s)
2024-02-29 13:22:52.779                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema "restricted-grandchild-1": 2024.01.24.1212
2024-02-29 13:22:52.779                  WARN 75 --- [           main] o.f.core.internal.command.DbMigrate      : outOfOrder mode is active. Migration of schema "restricted-grandchild-1" may not be reproducible.
2024-02-29 13:22:52.780                  INFO 75 --- [           main] o.f.core.internal.command.DbMigrate      : Schema "restricted-grandchild-1" is up to date. No migration necessary.
2024-02-29 13:22:52.781                  INFO 75 --- [           main] c.a.zonkytest.core.config.FlywayConfig   : Flyway migration progress: 8/8
2024-02-29 13:22:52.920                  INFO 75 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@7a9bd5ff, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@7e5de1e, org.springframework.security.web.context.SecurityContextPersistenceFilter@1d9d6b29, org.springframework.security.web.header.HeaderWriterFilter@5307e9c4, org.springframework.web.filter.CorsFilter@13c17604, org.springframework.security.web.csrf.CsrfFilter@449be5ff, org.springframework.security.web.authentication.logout.LogoutFilter@481a01cb, org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationFilter@7aac4077, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@53daac0, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@12018bb7, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@223f086a, org.springframework.security.web.session.SessionManagementFilter@18edaab, org.springframework.security.web.access.ExceptionTranslationFilter@6ddbe6fc, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1aeba3a0]
2024-02-29 13:22:54.564                  INFO 75 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 6 endpoint(s) beneath base path '/actuator'
2024-02-29 13:22:54.644                  INFO 75 --- [           main] c.a.zonkytest.core.config.CacheConfigIT  : Started CacheConfigIT in 5.352 seconds (JVM running for 183.944)
2024-02-29 13:22:54.724                  INFO 75 --- [           main] i.z.t.d.l.EmbeddedDatabaseReporter       : JDBC URL to connect to 'dataSource': url='jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq?user=postgres&password=docker', scope='CacheConfigIT#shouldCache_null'
2024-02-29 13:22:54.840                  INFO 75 --- [           main] i.z.t.d.l.EmbeddedDatabaseReporter       : JDBC URL to connect to 'dataSource': url='jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq?user=postgres&password=docker', scope='CacheConfigIT#shouldAlwaysUseSameCache'
2024-02-29 13:22:54.951                  INFO 75 --- [           main] i.z.t.d.l.EmbeddedDatabaseReporter       : JDBC URL to connect to 'dataSource': url='jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq?user=postgres&password=docker', scope='CacheConfigIT#shouldSeparateCaches'
2024-02-29 13:22:55.063                  INFO 75 --- [           main] i.z.t.d.l.EmbeddedDatabaseReporter       : JDBC URL to connect to 'dataSource': url='jdbc:postgresql://172.17.0.1:33574/bptarbubgjhq?user=postgres&password=docker', scope='CacheConfigIT#shouldCache'
188763 [INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.88 s - in c.a.zonkytest.core.config.CacheConfigIT
188763 [INFO] Running c.a.zonkytest.app.common.user.UserScenarioIT
2024-02-29 13:22:55.169                  INFO 75 --- [           main] .b.t.c.SpringBootTestContextBootstrapper : Neither @ContextConfiguration nor @ContextHierarchy found for test class [c.a.zonkytest.app.common.user.UserScenarioIT], using SpringBootContextLoader
2024-02-29 13:22:55.169                  INFO 75 --- [           main] o.s.t.c.support.AbstractContextLoader    : Could not detect default resource locations for test class [c.a.zonkytest.app.common.user.UserScenarioIT]: no resource found for suffixes {-context.xml, Context.groovy}.
2024-02-29 13:22:55.169                  INFO 75 --- [           main] t.c.s.AnnotationConfigContextLoaderUtils : Could not detect default configuration classes for test class [c.a.zonkytest.app.common.user.UserScenarioIT]: UserScenarioIT does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
2024-02-29 13:22:55.175                  INFO 75 --- [           main] .b.t.c.SpringBootTestContextBootstrapper : Found @SpringBootConfiguration c.a.zonkytest.Application for test class c.a.zonkytest.app.common.user.UserScenarioIT
2024-02-29 13:22:55.176                  INFO 75 --- [           main] .b.t.c.SpringBootTestContextBootstrapper : Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener, org.springframework.security.test.context.support.ReactorContextTestExecutionListener, io.zonky.test.db.EmbeddedDatabaseTestExecutionListener, io.zonky.test.db.event.EventPublishingTestExecutionListener, io.zonky.test.db.flyway.OptimizedFlywayTestExecutionListener]
2024-02-29 13:22:55.177                  INFO 75 --- [           main] .b.t.c.SpringBootTestContextBootstrapper : Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@2a32dae9, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@31f9ddcb, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@2e4f9cdc, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@52d20970, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@6e8b6451, org.springframework.test.context.support.DirtiesContextTestExecutionListener@1163fbce, io.zonky.test.db.EmbeddedDatabaseTestExecutionListener@43183c42, io.zonky.test.db.flyway.OptimizedFlywayTestExecutionListener@1c324d8, org.springframework.test.context.transaction.TransactionalTestExecutionListener@345f615d, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@3a6c5193, org.springframework.test.context.event.EventPublishingTestExecutionListener@381490b0, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener@20e9968e, org.springframework.security.test.context.support.ReactorContextTestExecutionListener@6f734e47, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@374b7af3, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@2b46fdba, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@477753ba, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@32033c65, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@5ef35434, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@42c4c97d, io.zonky.test.db.event.EventPublishingTestExecutionListener@3f53a81c]
2024-02-29 13:22:55.185                  INFO 75 --- [           main] i.z.t.d.l.EmbeddedDatabaseReporter       : JDBC URL to connect to 'dataSource': url='jdbc:postgresql://172.17.0.1:33574/odkfqaitkiqy?user=postgres&password=docker', scope='UserScenarioIT#userGet'
2024-02-29 13:22:55.193                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.191 UTC [1854] LOG:  TimescaleDB background worker scheduler for database 34009 will be stopped
2024-02-29 13:22:55.193                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.191 UTC [1854] STATEMENT:  DROP DATABASE IF EXISTS kssfrdhrxmoh
2024-02-29 13:22:55.193                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.191 UTC [27] LOG:  TimescaleDB background worker limit of 8 exceeded
2024-02-29 13:22:55.193                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.191 UTC [27] HINT:  Consider increasing timescaledb.max_background_workers.
2024-02-29 13:22:55.193                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.191 UTC [1605] LOG:  terminating TimescaleDB job scheduler due to administrator command
2024-02-29 13:22:55.193                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.191 UTC [1605] FATAL:  terminating connection due to administrator command
2024-02-29 13:22:55.194                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.193 UTC [1] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 1605) exited with exit code 1
2024-02-29 13:22:55.195                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.194 UTC [1782] LOG:  terminating TimescaleDB job scheduler due to administrator command
2024-02-29 13:22:55.195                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.194 UTC [1782] FATAL:  terminating connection due to administrator command
2024-02-29 13:22:55.196                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.195 UTC [1] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 1782) exited with exit code 1
2024-02-29 13:22:55.331                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.331 UTC [1814] ERROR:  source database "uqlipbuiagmk" is being accessed by other users
2024-02-29 13:22:55.332                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.331 UTC [1814] DETAIL:  There is 1 other session using the database.
2024-02-29 13:22:55.332                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:22:55.331 UTC [1814] STATEMENT:  CREATE DATABASE gbgkwixyzcda TEMPLATE uqlipbuiagmk OWNER postgres ENCODING 'utf8'
2024-02-29 13:22:55.398                  INFO 75 --- [           main] i.z.t.d.l.EmbeddedDatabaseReporter       : JDBC URL to connect to 'dataSource': url='jdbc:postgresql://172.17.0.1:33574/odkfqaitkiqy?user=postgres&password=docker', scope='UserScenarioIT#usrGetMe_saveInRootAndTargetTenant'

[...]

2024-02-29 13:23:29.140                  INFO 75 --- [           main] c.a.z.app.permitted.PermittedAspectIT    : Starting PermittedAspectIT using Java 21.0.2 with PID 75 (started by root in /builds/zonkytest-ac/zonkytest/zonkytest)
2024-02-29 13:23:29.140                  INFO 75 --- [           main] c.a.z.app.permitted.PermittedAspectIT    : The following 1 profile is active: "test"
2024-02-29 13:23:29.483                  INFO 75 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-02-29 13:23:29.534                  INFO 75 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 50 ms. Found 14 JPA repository interfaces.
2024-02-29 13:23:29.605                  INFO 75 --- [           main] EmbeddedDatabaseContextCustomizerFactory : Replacing 'dataSource' DataSource bean with embedded version
2024-02-29 13:23:29.609                  INFO 75 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=dfdef104-1b56-392e-a8d5-fa3b1a76d34c
2024-02-29 13:23:29.689                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration' of type [org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:23:29.690                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:23:29.691                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerClientsDefaultsMappingsProvider' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration$$Lambda$868/0x0000000801225810] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:23:29.692                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'defaultsBindHandlerAdvisor' of type [org.springframework.cloud.commons.config.DefaultsBindHandlerAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:23:29.693                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration' of type [org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:23:29.694                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'stringOrNumberMigrationVersionConverter' of type [org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$StringOrNumberToMigrationVersionConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:23:29.698                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.sleuth.jdbc-org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.TraceJdbcProperties' of type [org.springframework.cloud.sleuth.autoconfig.instrument.jdbc.TraceJdbcProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:23:29.753                  INFO 75 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'io.zonky.test.db.config.EmbeddedDatabaseAutoConfiguration' of type [io.zonky.test.db.config.EmbeddedDatabaseAutoConfiguration$$EnhancerBySpringCGLIB$$3420a2ee] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-02-29 13:23:29.843                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 8.5.13 by Redgate
2024-02-29 13:23:29.843                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#8.5.13
2024-02-29 13:23:29.843                  INFO 75 --- [           main] o.f.c.internal.license.VersionPrinter    : 
2024-02-29 13:23:29.847                  WARN 75 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [ca/zonkytest/zonkytest/core/config/FlywayConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is io.zonky.test.db.shaded.com.google.common.util.concurrent.UncheckedExecutionException: io.zonky.test.db.provider.ProviderException: Unexpected error when creating a database; nested exception is org.postgresql.util.PSQLException: ERROR: source database "uqlipbuiagmk" is being accessed by other users
  Detail: There is 1 other session using the database.
2024-02-29 13:23:29.853                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:23:29.852 UTC [27] LOG:  TimescaleDB background worker limit of 8 exceeded
2024-02-29 13:23:29.853                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:23:29.852 UTC [27] HINT:  Consider increasing timescaledb.max_background_workers.
2024-02-29 13:23:29.853                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:23:29.852 UTC [2164] LOG:  terminating TimescaleDB job scheduler due to administrator command
2024-02-29 13:23:29.853                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:23:29.852 UTC [2164] FATAL:  terminating connection due to administrator command
2024-02-29 13:23:29.853                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:23:29.853 UTC [1] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 2164) exited with exit code 1
2024-02-29 13:23:29.859                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:23:29.856 UTC [2730] LOG:  terminating TimescaleDB scheduler entrypoint due to administrator command
2024-02-29 13:23:29.859                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:23:29.857 UTC [2730] FATAL:  terminating connection due to administrator command
2024-02-29 13:23:29.859                  INFO 75 --- [ream-1536986736] z.t.d.p.p.DockerPostgresDatabaseProvider : STDERR: 2024-02-29 13:23:29.857 UTC [1] LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 2730) exited with exit code 1
2024-02-29 13:23:29.862                  INFO 75 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2024-02-29 13:23:29.885                 ERROR 75 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [pkg/core/config/FlywayConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is io.zonky.test.db.shaded.com.google.common.util.concurrent.UncheckedExecutionException: io.zonky.test.db.provider.ProviderException: Unexpected error when creating a database; nested exception is org.postgresql.util.PSQLException: ERROR: source database "uqlipbuiagmk" is being accessed by other users
  Detail: There is 1 other session using the database.
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:132)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
    at io.zonky.test.db.EmbeddedDatabaseTestExecutionListener.forEachDatabase(EmbeddedDatabaseTestExecutionListener.java:90)
    at io.zonky.test.db.EmbeddedDatabaseTestExecutionListener.resetDatabases(EmbeddedDatabaseTestExecutionListener.java:58)
    at io.zonky.test.db.EmbeddedDatabaseTestExecutionListener.beforeTestClass(EmbeddedDatabaseTestExecutionListener.java:34)
    at org.springframework.test.context.TestContextManager.beforeTestClass(TestContextManager.java:213)
    at org.springframework.test.context.junit.jupiter.SpringExtension.beforeAll(SpringExtension.java:113)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$10(ClassBasedTestDescriptor.java:381)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:381)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:205)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:80)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:148)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150)
    at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is io.zonky.test.db.shaded.com.google.common.util.concurrent.UncheckedExecutionException: io.zonky.test.db.provider.ProviderException: Unexpected error when creating a database; nested exception is org.postgresql.util.PSQLException: ERROR: source database "uqlipbuiagmk" is being accessed by other users
  Detail: There is 1 other session using the database.
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
    ... 63 common frames omitted
Caused by: io.zonky.test.db.shaded.com.google.common.util.concurrent.UncheckedExecutionException: io.zonky.test.db.provider.ProviderException: Unexpected error when creating a database; nested exception is org.postgresql.util.PSQLException: ERROR: source database "uqlipbuiagmk" is being accessed by other users
  Detail: There is 1 other session using the database.
    at io.zonky.test.db.shaded.com.google.common.util.concurrent.Futures.wrapAndThrowUnchecked(Futures.java:1546)
    at io.zonky.test.db.shaded.com.google.common.util.concurrent.Futures.getUnchecked(Futures.java:1532)
    at io.zonky.test.db.context.DefaultDatabaseContext.awaitDatabase(DefaultDatabaseContext.java:282)
    at io.zonky.test.db.context.DefaultDatabaseContext.getDatabase(DefaultDatabaseContext.java:126)
    at io.zonky.test.db.context.DatabaseTargetSource.getTarget(DatabaseTargetSource.java:32)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:195)
    at jdk.proxy2/jdk.proxy2.$Proxy201.getConnection(Unknown Source)
    at net.ttddyy.dsproxy.support.ProxyDataSource.getConnection(ProxyDataSource.java:72)
    at org.springframework.jdbc.datasource.DelegatingDataSource.getConnection(DelegatingDataSource.java:99)
    at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:48)
    at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:75)
    at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:147)
    at org.flywaydb.core.Flyway.migrate(Flyway.java:124)
    at c.a.zonkytest.core.config.FlywayConfig.flyway(FlywayConfig.java:40)
    at c.a.zonkytest.core.config.FlywayConfig$$EnhancerBySpringCGLIB$$4c2e23c8.CGLIB$flyway$1(<generated>)
    at c.a.zonkytest.core.config.FlywayConfig$$EnhancerBySpringCGLIB$$4c2e23c8$$FastClassBySpringCGLIB$$bf98d39e.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
    at c.a.zonkytest.core.config.FlywayConfig$$EnhancerBySpringCGLIB$$4c2e23c8.flyway(<generated>)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 64 common frames omitted
Caused by: io.zonky.test.db.provider.ProviderException: Unexpected error when creating a database; nested exception is org.postgresql.util.PSQLException: ERROR: source database "uqlipbuiagmk" is being accessed by other users
  Detail: There is 1 other session using the database.
    at io.zonky.test.db.provider.postgres.DockerPostgresDatabaseProvider.createDatabase(DockerPostgresDatabaseProvider.java:119)
    at io.zonky.test.db.provider.common.TemplatingDatabaseProvider$TemplateWrapper.createDatabase(TemplatingDatabaseProvider.java:251)
    at io.zonky.test.db.provider.common.TemplatingDatabaseProvider.createDatabase(TemplatingDatabaseProvider.java:114)
    at io.zonky.test.db.provider.common.TemplatingDatabaseProvider.createDatabase(TemplatingDatabaseProvider.java:104)
    at io.zonky.test.db.provider.common.PrefetchingDatabaseProvider$PrefetchingTask.lambda$forPreparer$0(PrefetchingDatabaseProvider.java:391)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at io.zonky.test.db.provider.common.PrefetchingDatabaseProvider$PrefetchingTask.run(PrefetchingDatabaseProvider.java:420)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.postgresql.util.PSQLException: ERROR: source database "uqlipbuiagmk" is being accessed by other users
  Detail: There is 1 other session using the database.
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2365)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:355)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:490)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:408)
    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:167)
    at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:156)
    at io.zonky.test.db.provider.postgres.DockerPostgresDatabaseProvider$DatabaseInstance.executeStatement(DockerPostgresDatabaseProvider.java:242)
    at io.zonky.test.db.provider.postgres.DockerPostgresDatabaseProvider$DatabaseInstance.createDatabase(DockerPostgresDatabaseProvider.java:206)
    at io.zonky.test.db.provider.postgres.DockerPostgresDatabaseProvider.createDatabase(DockerPostgresDatabaseProvider.java:114)
    ... 9 common frames omitted
tomix26 commented 5 months ago

Hey @jomatt, sorry for the slightly delayed response.

First off, let me try to outline how the library works. At the start of the application (initialization of the testing context), a template database is created which holds the default state from which each test is run. The issue is a bit more complicated because there may actually be multiple template databases, but that's not important right now. Before a test is run, an isolated database is created for the specific test method as a clone from the previously prepared template database. To use the template database for this purpose, there must be no active connections to it, which is a restriction imposed by PostgreSQL. And that's the source of the above error source database "uqlipbuiagmk" is being accessed by other users, where a new test database cannot be created because there is an active connection to the template database.

There could be several reasons for this, here are a few that come to mind:

Try going through your codebase to see if it contains any of the above issues. If you struggle to find the problem, you can try to pause the code using a breakpoint and use database tools to list details about the hanging connection. Perhaps it will guide you in the right direction.