velocious 1.0.586 → 1.0.587
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.
- package/README.md +1 -1
- package/build/database/drivers/base.js +7 -0
- package/build/database/drivers/mysql/index.js +24 -1
- package/build/database/pool/async-tracked-multi-connection.js +1 -0
- package/build/src/database/drivers/base.d.ts +6 -0
- package/build/src/database/drivers/base.d.ts.map +1 -1
- package/build/src/database/drivers/base.js +7 -1
- package/build/src/database/drivers/mysql/index.d.ts +8 -0
- package/build/src/database/drivers/mysql/index.d.ts.map +1 -1
- package/build/src/database/drivers/mysql/index.js +24 -2
- package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
- package/build/src/database/pool/async-tracked-multi-connection.js +2 -1
- package/package.json +1 -1
- package/src/database/drivers/base.js +7 -0
- package/src/database/drivers/mysql/index.js +24 -1
- package/src/database/pool/async-tracked-multi-connection.js +1 -0
package/package.json
CHANGED
|
@@ -233,6 +233,13 @@ export default class VelociousDatabaseDriversBase {
|
|
|
233
233
|
this._schemaCache = new Map()
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Cleans driver-specific session state before this logical connection is reusable.
|
|
238
|
+
* Drivers whose physical sessions cannot be safely reset should dispose them here.
|
|
239
|
+
* @returns {Promise<void>} - Resolves when the next checkout cannot observe prior session state.
|
|
240
|
+
*/
|
|
241
|
+
async cleanupSessionStateAfterCheckout() {}
|
|
242
|
+
|
|
236
243
|
/**
|
|
237
244
|
* Runs add foreign key.
|
|
238
245
|
* @param {string} tableName - Table name.
|
|
@@ -65,11 +65,34 @@ export default class VelociousDatabaseDriversMysql extends Base{
|
|
|
65
65
|
* @returns {Promise<void>} - Resolves when complete.
|
|
66
66
|
*/
|
|
67
67
|
async _close() {
|
|
68
|
-
|
|
68
|
+
const pool = this.pool
|
|
69
|
+
|
|
70
|
+
if (!pool) return
|
|
71
|
+
|
|
72
|
+
await new Promise((resolve, reject) => {
|
|
73
|
+
pool.end((error) => {
|
|
74
|
+
if (error) {
|
|
75
|
+
reject(error)
|
|
76
|
+
} else {
|
|
77
|
+
resolve(undefined)
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
})
|
|
69
81
|
this.pool = undefined
|
|
70
82
|
this.resetCurrentSessionTimeZone()
|
|
71
83
|
}
|
|
72
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Disposes the physical MySQL session after each logical pool checkout.
|
|
87
|
+
* MySQL exposes open-ended session state, so reconnecting is safer than trying
|
|
88
|
+
* to enumerate and reset variables, temporary tables, prepared statements,
|
|
89
|
+
* SQL modes, and other caller-controlled state.
|
|
90
|
+
* @returns {Promise<void>} - Resolves after the physical session is closed.
|
|
91
|
+
*/
|
|
92
|
+
async cleanupSessionStateAfterCheckout() {
|
|
93
|
+
await this._close()
|
|
94
|
+
}
|
|
95
|
+
|
|
73
96
|
/**
|
|
74
97
|
* Runs set connection checkout name.
|
|
75
98
|
* @param {string | undefined} name - Human-readable name for this active checkout.
|
|
@@ -150,6 +150,7 @@ export default class VelociousDatabasePoolAsyncTrackedMultiConnection extends Ba
|
|
|
150
150
|
await this.rollbackLeftOpenTransaction(connection)
|
|
151
151
|
await connection.releaseHeldAdvisoryLocks()
|
|
152
152
|
await connection.clearConnectionCheckoutName()
|
|
153
|
+
await connection.cleanupSessionStateAfterCheckout()
|
|
153
154
|
} catch (error) {
|
|
154
155
|
await this.closeCheckedOutConnectionAfterCheckinFailure(connection, id, error)
|
|
155
156
|
throw error
|