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

Keep seed router address in the pool after routing table #931

Open
wants to merge 1 commit into
base: 4.4
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider

async _updateRoutingTable (newRoutingTable, onDatabaseNameResolved) {
// close old connections to servers not present in the new routing table
await this._connectionPool.keepAll(newRoutingTable.allServers())
await this._connectionPool.keepAll([...newRoutingTable.allServers(), this._seedRouter])
this._routingTableRegistry.removeExpired()
this._routingTableRegistry.register(
newRoutingTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,47 @@ describe('#unit RoutingConnectionProvider', () => {
})
}, 10000)

it.each(usersDataSet)('keeps the seed router in the pool after [user=%s]', (user, done) => {
const pool = newPool()
const updatedRoutingTable = newRoutingTable(
null,
[serverA, serverB],
[serverC, serverD],
[serverE, serverF]
)

const connectionProvider = newRoutingConnectionProviderWithSeedRouter(
server0,
[server0], // seed router address resolves just to itself
[
newRoutingTable(
null,
[server1, server2, server3],
[server4, server5],
[server6, server7],
int(0) // expired routing table
)
],
{
null: {
'server1:7687': null, // returns no routing table
'server2:7687': null, // returns no routing table
'server3:7687': null, // returns no routing table
'server0:7687': updatedRoutingTable
}
},
pool
)

connectionProvider
.acquireConnection({ accessMode: READ, database: null, impersonatedUser: user })
.then(connection => {
expect(connection.address).toEqual(serverC)
expect(pool.has(server0)).toBeTruthy()

}).finally(done)
}, 10000)

it.each(usersDataSet)('refreshes routing table without readers to get read connection [user=%s]', (user, done) => {
const pool = newPool()
const updatedRoutingTable = newRoutingTable(
Expand Down