Skip to content

Fixed purging of connections after rediscovery #212

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

Merged
merged 1 commit into from
Mar 2, 2017
Merged
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
2 changes: 1 addition & 1 deletion src/v1/routing-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class RoutingDriver extends Driver {

// close old connections to servers not present in the new routing table
const staleServers = currentRoutingTable.serversDiff(newRoutingTable);
staleServers.forEach(server => this._pool.purge);
staleServers.forEach(server => this._pool.purge(server));

// make this driver instance aware of the new table
this._routingTable = newRoutingTable;
Expand Down
31 changes: 31 additions & 0 deletions test/v1/routing.driver.boltkit.it.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,37 @@ describe('routing driver', () => {
});
});

it('should purge connections to stale servers after routing table refresh', done => {
if (!boltkit.BoltKitSupport) {
done();
return;
}

const kit = new boltkit.BoltKit();
const router = kit.start('./test/resources/boltkit/acquire_endpoints.script', 9042);
const reader = kit.start('./test/resources/boltkit/read_server.script', 9005);

kit.run(() => {
const driver = newDriver('bolt+routing://127.0.0.1:9042');
const session = driver.session(neo4j.session.READ);
session.run('MATCH (n) RETURN n.name').then(() => {
session.close();

expect(driver._pool.has('127.0.0.1:9042')).toBeFalsy();
expect(driver._pool.has('127.0.0.1:9005')).toBeTruthy();

driver.close();
router.exit(routerCode => {
reader.exit(readerCode => {
expect(routerCode).toEqual(0);
expect(readerCode).toEqual(0);
done();
});
});
});
});
});

it('should discover new servers', done => {
if (!boltkit.BoltKitSupport) {
done();
Expand Down