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.

Transaction cancelled when index does not exist

See original GitHub issue

If there is a query inside a transaction, and index on the field is not created yet, then after query executes transaction is in the Canceled state.

That happens because when there is no index, IndexNotFoundException is thrown first, and inner transaction in DbEngine.Find is rolled back (and outer transaction cancelled). Upper in the stack exception get caught and index created, and query succeeds. But outer transaction could not be committed because it’s cancelled.

Test to reproduce:

    [TestMethod]
    public void TestIndexCreationInsideTransaction()
    {
        using (var tmp = new TempFile())
        {
            using (var db = new LiteDatabase(tmp.ConnectionString))
            {
                var col = db.GetCollection("col");

                using (var trans = db.BeginTrans())
                {
                    col.Insert(new BsonDocument().Add("test", 0));

                    var query = Query.EQ("test", 0);
                    // Index is created here
                    col.Find(query).ToList();

                    // Fails with TransactionCanceledException
                    trans.Commit();
                }
            }
        }
    }

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
sherry-ummencommented, Sep 13, 2016

All clear. I understand now. Thanks for clearing this up

1reaction
mbdavidcommented, Sep 13, 2016

Hi @baSSiLL, I will try to take a look on this. I’m out of time for last days. Transactions will be die 😃 To be thread safe, next version will not support transactions (ACID will be only in document level).

Read more comments on GitHub >

github_iconTop Results From Across the Web

TransactionCanceledException (AWS SDK for Java - 1.12.533)
There is insufficient provisioned capacity for the transaction to be completed. An item size becomes too large (larger than 400 KB), or a...
Read more >
Troubleshoot TransactWriteItems API failing with Amazon ...
There are a number of reasons that a TransactWriteItems request might fail or ... "message": "Transaction cancelled, please refer cancellation reasons for ...
Read more >
Create index CONCURRENTLY in PostgreSQL
Because of this the index does not exist when the transaction is aborted (the create index statement is canceled). When you build the...
Read more >
TransactionCanceledException (AWS SDK for Java
There is insufficient provisioned capacity for the transaction to be completed. An item size becomes too large (larger than 400 KB), or a...
Read more >
TransactWriteItems - Amazon DynamoDB - AWS Documentation
The entire transaction request was canceled. DynamoDB cancels a TransactWriteItems request under the following circumstances:
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