in common/lib/plugins/failover/reader_failover_handler.ts [111:140]
async internalFailoverTask(hosts: HostInfo[], currentHost: HostInfo | null, endTime: number): Promise<ReaderFailoverResult> {
while (Date.now() <= endTime) {
const result = await this.failoverInternal(hosts, currentHost);
if (result.client && result.newHost && result.isConnected) {
if (!this.enableFailoverStrictReader) {
return result; // connection to any host is acceptable
}
// Ensure new connection is to a reader host
await this.pluginService.refreshHostList();
try {
if ((await this.pluginService.getHostRole(result.client)) === HostRole.READER) {
return result;
}
} catch (error) {
logger.debug(Messages.get("ClusterAwareReaderFailoverHandler.errorGettingHostRole", error.message));
}
try {
await this.pluginService.abortTargetClient(result.client);
} catch (error) {
// ignore
}
await sleep(1000);
} else {
await sleep(1000);
}
}
throw new InternalQueryTimeoutError(Messages.get("Failover.timeoutError"));
}