Skip to content

Spanner: RESOURCE_EXHAUSTED No session available in the pool.  #3786

@lascarayf

Description

@lascarayf

I am using the Spanner client library for Java and i configure the client using Spring (Java 10 and Docker)

After a while, the application start to log the following message but i don't understand why. The application concurrency is minimal. It's seem the sessions aren't reused.

I monitor the session with Stackdriver and they are below 20.

If i remove setFailIfPoolExhausted the applicacion hang instead of throwing exception RESOURCE_EXHAUSTED.

RESOURCE_EXHAUSTED: No session available in the pool. Maximum number of sessions in the pool can be overridden by invoking SessionPoolOptions#Builder#setMaxSessions. Client can be made to block rather than fail by setting SessionPoolOptions#Builder#setBlockIfPoolExhausted.

@Configuration
public class SpannerConfig {

    @Value("${datasource.instanceId}")
    private String instance;

    @Value("${datasource.databaseId}")
    private String database;

    @Bean
    public Spanner spannerService() throws IOException {

        SessionPoolOptions sessionPoolOptions = SessionPoolOptions.newBuilder()
                .setFailIfPoolExhausted()
                .setMinSessions(5)
                .setMaxSessions(100)
                .build();

        SpannerOptions options = SpannerOptions.newBuilder()
                .setSessionPoolOption(sessionPoolOptions)
                .build();

        return options.getService();
    }


    @Bean
    public DatabaseClient spannerClient(Spanner spannerService) {
        DatabaseId databaseId = DatabaseId.of(spannerService.getOptions().getProjectId(), instance, database);
        return spannerService.getDatabaseClient(databaseId);
    }
}

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the Spanner API.priority: p2Moderately-important priority. Fix may not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions