throw clear error about unavailable db nodes
This commit is contained in:
parent
a82dacdc30
commit
e3e7623c27
@ -337,6 +337,9 @@ class MariaDB
|
|||||||
const pool = this.#pool;
|
const pool = this.#pool;
|
||||||
if (nodeName)
|
if (nodeName)
|
||||||
{
|
{
|
||||||
|
const available = this.#nodes.filter(n => n.status === 'synced');
|
||||||
|
if (!available.length)
|
||||||
|
throw new Error('No nodes available for query');
|
||||||
const node = this.#nodes.find(n => n.name === nodeName);
|
const node = this.#nodes.find(n => n.name === nodeName);
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
@ -358,7 +361,7 @@ class MariaDB
|
|||||||
this.#logger.debug(`Selected node ${nodeName} for query`);
|
this.#logger.debug(`Selected node ${nodeName} for query`);
|
||||||
return pool.of(nodeName ?? '*').getConnection((err, conn) =>
|
return pool.of(nodeName ?? '*').getConnection((err, conn) =>
|
||||||
{
|
{
|
||||||
if (err)
|
if (err)
|
||||||
return reject(err);
|
return reject(err);
|
||||||
return resolve(conn);
|
return resolve(conn);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user