@hotmeshio/hotmesh 0.20.0 → 0.20.1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -201,6 +201,13 @@ async function ensureProcedures(client, schemaName) {
201
201
  * statement-level form. Recreating a trigger takes an ACCESS EXCLUSIVE
202
202
  * lock on the table, so only do it when the installed trigger is still
203
203
  * row-level (tgtype bit 0 set); subsequent boots are a no-op.
204
+ *
205
+ * The function replacement and trigger swap MUST commit atomically:
206
+ * between them, the still-installed row-level trigger would invoke the
207
+ * statement-level function body, whose transition-table reference
208
+ * (new_rows) errors under FOR EACH ROW — failing every concurrent
209
+ * INSERT until the swap lands (or indefinitely, if the migrating
210
+ * process dies between the two statements).
204
211
  */
205
212
  async function ensureStatementLevelTriggers(client, schemaName) {
206
213
  const result = await client.query(`SELECT count(*) AS row_level
@@ -212,7 +219,15 @@ async function ensureStatementLevelTriggers(client, schemaName) {
212
219
  AND t.tgname IN ('notify_engine_stream_insert', 'notify_worker_stream_insert')
213
220
  AND (t.tgtype & 1) = 1`, [schemaName]);
214
221
  if (parseInt(result.rows[0].row_level, 10) > 0) {
215
- await createNotificationTriggers(client, schemaName);
222
+ await client.query('BEGIN');
223
+ try {
224
+ await createNotificationTriggers(client, schemaName);
225
+ await client.query('COMMIT');
226
+ }
227
+ catch (error) {
228
+ await client.query('ROLLBACK');
229
+ throw error;
230
+ }
216
231
  }
217
232
  }
218
233
  async function createTables(client, schemaName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",