question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically pass transactions to all queries in automanaged transaction not works

See original GitHub issue

What you are doing?

two operations inside automatic transaction

    result = await models.sequelize.transaction(async() => {
      model = await models[type].create(plain)
      attachment = await models.File.findById(EACH_ATTACHMENT)
    })

What do you expect to happen?

i wana see transaction and two operations (create and select) inside it

What is actually happening?

transaction opened, then create operation inside it, then select operation outside it (see logs)

Output, either JSON or SQL

[2017-09-09 22:44:40.329] [INFO] console - Executing (6d360132-f594-46c3-8355-74ad34aa759e): START TRANSACTION; [2017-09-09 22:44:40.330] [INFO] console - Executing (6d360132-f594-46c3-8355-74ad34aa759e): SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; [2017-09-09 22:44:40.338] [INFO] console - Executing (6d360132-f594-46c3-8355-74ad34aa759e): INSERT INTO “Zemla” (“id”,“name”,“level”,“obshinaSize”,“path”,“created_at”,“updated_at”,“parent_id”) VALUES (DEFAULT,‘unit test’,0,0,‘/1/’,‘2017-09-09 17:44:40.331 +00:00’,‘2017-09-09 17:44:40.331 +00:00’,1) RETURNING *; [2017-09-09 22:44:40.352] [INFO] console - Executing (default): SELECT “id”, “name”, “path”, “note”, “mimeType”, “size”, “created_at”, “updated_at”, “deleted_at”, “kopa_id”, “owner_id”, “zemla_id”, “kopnik_id”, “predlozhenie_id”, “slovo_id”, “golos_id”, “registration_id” FROM “File” AS “File” WHERE (“File”.“deleted_at” IS NULL AND “File”.“id” = 1); [2017-09-09 22:44:57.603] [INFO] console - Executing (default): UPDATE “File” SET “zemla_id”=‘180’,“updated_at”=‘2017-09-09 17:44:57.590 +00:00’ WHERE “id” = ‘1’

__Dialect:__postgres __Database version:9.5 __Sequelize version:3.30.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
Alexseycommented, Sep 11, 2017

Actually it looks like a bug that INSERT operation is performing in transaction

0reactions
Alexseycommented, Apr 26, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can i pass transaction to each query automatically using ...
You can use CLS: const cls = require('cls-hooked'); const Sequelize = require('@sequelize/core'); const namespace = cls.
Read more >
Transactions - Sequelize
Sequelize does not use transactions by default. ... To automatically pass the transaction to all queries you must install the cls-hooked (CLS) module...
Read more >
Managed transaction (auto-callback) - Manual | Sequelize
Sequelize supports two ways of using transactions: ... To automatically pass the transaction to all queries you must install the continuation local storage...
Read more >
Features Overview | Moneris Developers
Since all batched transactions are sent in a single file, there is no risk of a transaction dropping or you having to reinitiate...
Read more >
Re: [IndexedDB] Detailed comments for the current draft from Nikunj ...
The Web IDL spec does not support a Date/Time data type. ... Clarification on transactions: all database operations that > affect the schema...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found