Make sure to release all db connections
This commit is contained in:
parent
19a564062b
commit
a1a2e9363f
@ -67,7 +67,14 @@ class PoolsParser {
|
|||||||
|
|
||||||
// Get existing pools from the db
|
// Get existing pools from the db
|
||||||
const connection = await DB.pool.getConnection();
|
const connection = await DB.pool.getConnection();
|
||||||
const [existingPools] = await connection.query<any>({ sql: 'SELECT * FROM pools;', timeout: 120000 });
|
let existingPools: any[] = [];
|
||||||
|
try {
|
||||||
|
existingPools = await connection.query<any>({ sql: 'SELECT * FROM pools;', timeout: 120000 });
|
||||||
|
} catch (e) {
|
||||||
|
logger.err('Unable to get existing pools from the database, skipping pools.json import');
|
||||||
|
connection.release();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, we generate the final consolidated pools data
|
// Finally, we generate the final consolidated pools data
|
||||||
const finalPoolDataAdd: Pool[] = [];
|
const finalPoolDataAdd: Pool[] = [];
|
||||||
@ -117,11 +124,11 @@ class PoolsParser {
|
|||||||
const updateQueries: string[] = [];
|
const updateQueries: string[] = [];
|
||||||
for (let i = 0; i < finalPoolDataUpdate.length; ++i) {
|
for (let i = 0; i < finalPoolDataUpdate.length; ++i) {
|
||||||
updateQueries.push(`
|
updateQueries.push(`
|
||||||
UPDATE pools
|
UPDATE pools
|
||||||
SET name='${finalPoolDataUpdate[i].name}', link='${finalPoolDataUpdate[i].link}',
|
SET name='${finalPoolDataUpdate[i].name}', link='${finalPoolDataUpdate[i].link}',
|
||||||
regexes='${JSON.stringify(finalPoolDataUpdate[i].regexes)}', addresses='${JSON.stringify(finalPoolDataUpdate[i].addresses)}'
|
regexes='${JSON.stringify(finalPoolDataUpdate[i].regexes)}', addresses='${JSON.stringify(finalPoolDataUpdate[i].addresses)}'
|
||||||
WHERE name='${finalPoolDataUpdate[i].name}'
|
WHERE name='${finalPoolDataUpdate[i].name}'
|
||||||
;`);
|
;`);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -158,6 +165,8 @@ class PoolsParser {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('Unable to insert "Unknown" mining pool');
|
logger.err('Unable to insert "Unknown" mining pool');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connection.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user