Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions db-service/lib/common/DatabaseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class DatabaseService extends cds.Service {

// Setting this.pool as used in this.acquire() and this.release()
this.pool = this.pools[tenant] ??= new ConnectionPool(this.pools._factory, tenant)
.on('factoryCreateError', e => {
if (isMultitenant && e.status === 404) {
this.pool._waitingClientsQueue?.dequeue?.()?.reject(e)
}
})

// Acquire a pooled connection
this.dbc = await this.acquire()
Expand Down
9 changes: 1 addition & 8 deletions hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ class HANAService extends SQLService {
HANAVERSION = dbc.server.major
return dbc
} catch (err) {
if (isMultitenant) {
// REVISIT: throw the error and break retry loop
// Stop trying when the tenant does not exist or is rate limited
if (err.status == 404 || err.status == 429)
return new Promise(function (_, reject) {
setTimeout(() => reject(err), acquireTimeoutMillis)
})
} else if (err.code !== 10) throw err
if (!isMultitenant && err.code !== 10) throw err
await require('@sap/cds-mtxs/lib').xt.serviceManager.get(tenant, { disableCache: true })
return this.create(tenant)
}
Expand Down
Loading