Skip to content
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

fix: do not keep references to invalidated clients #1093

Merged
merged 1 commit into from Apr 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -92,9 +92,6 @@ private static String nextDatabaseClientId(DatabaseId databaseId) {

private final CloseableExecutorProvider asyncExecutorProvider;

@GuardedBy("this")
private final List<DatabaseClientImpl> invalidatedDbClients = new ArrayList<>();

@GuardedBy("this")
private final Map<DatabaseId, SessionClient> sessionClients = new HashMap<>();

Expand Down Expand Up @@ -204,9 +201,8 @@ public DatabaseClient getDatabaseClient(DatabaseId db) {
checkClosed();
String clientId = null;
if (dbClients.containsKey(db) && !dbClients.get(db).pool.isValid()) {
// Move the invalidated client to a separate list, so we can close it together with the
// other database clients when the Spanner instance is closed.
invalidatedDbClients.add(dbClients.get(db));
// Close the invalidated client and remove it.
dbClients.get(db).closeAsync(new ClosedException());
clientId = dbClients.get(db).clientId;
dbClients.remove(db);
}
Expand Down Expand Up @@ -253,8 +249,7 @@ void close(long timeout, TimeUnit unit) {
checkClosed();
closedException = new ClosedException();
closureFutures = new ArrayList<>();
invalidatedDbClients.addAll(dbClients.values());
for (DatabaseClientImpl dbClient : invalidatedDbClients) {
for (DatabaseClientImpl dbClient : dbClients.values()) {
closureFutures.add(dbClient.closeAsync(closedException));
}
dbClients.clear();
Expand Down