badmfck-api-server 3.8.8 → 3.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -242,7 +242,6 @@ class MysqlAdapter {
|
|
242
242
|
}
|
243
243
|
if (this.options.debug)
|
244
244
|
(0, LogService_1.logDB)("Commit transaction:", trx.id);
|
245
|
-
this.transactions = this.transactions.filter(i => i.id !== trxid);
|
246
245
|
if (this.options.debug)
|
247
246
|
(0, LogService_1.logDB)("Transaction pool:", this.transactions);
|
248
247
|
const err = await this.commit(trx);
|
@@ -439,6 +438,9 @@ class MysqlAdapter {
|
|
439
438
|
};
|
440
439
|
}
|
441
440
|
}
|
441
|
+
let trx = null;
|
442
|
+
if (request.transactionID)
|
443
|
+
trx = this.transactions.find(i => i.id === request.transactionID);
|
442
444
|
try {
|
443
445
|
let result = null;
|
444
446
|
if (this.options.maxQueryTimeout && this.options.maxQueryTimeout > 0)
|
@@ -448,6 +450,8 @@ class MysqlAdapter {
|
|
448
450
|
this.lastSuccessQueryTime = +new Date();
|
449
451
|
if (!request.transactionID && doCloseConnection)
|
450
452
|
this.finalizeConnection(conn);
|
453
|
+
if (trx)
|
454
|
+
trx.queries.push({ sql: query, status: "ok" });
|
451
455
|
return {
|
452
456
|
data: result[0],
|
453
457
|
error: null,
|
@@ -458,11 +462,6 @@ class MysqlAdapter {
|
|
458
462
|
};
|
459
463
|
}
|
460
464
|
catch (e) {
|
461
|
-
if (request.transactionID) {
|
462
|
-
const trx = this.transactions.find(i => i.id === request.transactionID);
|
463
|
-
if (trx)
|
464
|
-
this.storeTransactionAsProblem(trx, query);
|
465
|
-
}
|
466
465
|
if (!request.transactionID && doCloseConnection)
|
467
466
|
this.finalizeConnection(conn);
|
468
467
|
else if (request.transactionID && request.throwable) {
|
@@ -474,10 +473,14 @@ class MysqlAdapter {
|
|
474
473
|
this.finalizeConnection(conn);
|
475
474
|
}
|
476
475
|
const error = this.createMysqlQueryError(e);
|
476
|
+
if (trx)
|
477
|
+
trx.queries.push({ sql: query, status: error.code });
|
477
478
|
if (`${e}`.indexOf('ECONNREFUSED') !== -1 || `${e}`.indexOf("PROTOCOL_") !== -1 || error.message.includes("closed state")) {
|
478
479
|
(0, LogService_1.logError)("Connection looks dead, recreating pool 1");
|
479
480
|
this.recreatePool();
|
480
481
|
}
|
482
|
+
if (trx)
|
483
|
+
this.storeTransactionAsProblem(trx, "error:" + error.errno);
|
481
484
|
if (request.throwable)
|
482
485
|
throw { ...DefaultErrors_1.default.DB_ERROR, details: error.message, stack: error };
|
483
486
|
return {
|
@@ -641,10 +644,14 @@ class MysqlAdapter {
|
|
641
644
|
await trx.conn.commit();
|
642
645
|
trx.conn.removeAllListeners();
|
643
646
|
trx.conn.release();
|
647
|
+
const trxIndex = this.transactions.indexOf(trx);
|
648
|
+
this.transactions.splice(trxIndex, 1);
|
644
649
|
}
|
645
650
|
catch (e) {
|
651
|
+
const err = this.createMysqlQueryError(e);
|
652
|
+
trx.queries.push({ sql: "COMMIT", status: err.code });
|
646
653
|
await this.rollbackTransaction(trx);
|
647
|
-
return
|
654
|
+
return err;
|
648
655
|
}
|
649
656
|
return null;
|
650
657
|
}
|
@@ -660,12 +667,13 @@ class MysqlAdapter {
|
|
660
667
|
this.transactions = this.transactions.filter(i => trx && i && i.id !== trx.id);
|
661
668
|
if (this.options.debug)
|
662
669
|
(0, LogService_1.logDB)("Rollback complete", trx.conn.threadId);
|
670
|
+
trx.queries.push({ sql: "ROLLBACK", status: "ok" });
|
663
671
|
}
|
664
672
|
catch (e) {
|
665
673
|
(0, LogService_1.logCrit)("MysqlAdapter", "Can't rollback transaction", trx.queries);
|
666
674
|
err = this.createMysqlQueryError(e);
|
675
|
+
trx.queries.push({ sql: "ROLLBACK", status: "fail" });
|
667
676
|
}
|
668
|
-
this.storeTransactionAsProblem(trx, "rollback");
|
669
677
|
return err;
|
670
678
|
}
|
671
679
|
async finish() {
|