Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindById leaves open cursors on transaction #1427

Closed
clooudch opened this issue Feb 1, 2020 · 4 comments
Closed

FindById leaves open cursors on transaction #1427

clooudch opened this issue Feb 1, 2020 · 4 comments

Comments

@clooudch
Copy link

clooudch commented Feb 1, 2020

It seems like the 'FindById' operation on the database (and potentially other operations as well), leave an open cursor on the transaction.

This can easily be reproduced. Just begin a transaction on the database and run a 'FindById' operation on a collection. You will see that you can not commit the transaction as it still contains open cursors.

I think this has something to do with the combination of 'FirstOrDefault' and IEnumerable functions. My guess is that the cursor will only be returned after the enumerator completed and 'FirstOrDefault' will stop the enumerator after the first element.

@clooudch
Copy link
Author

clooudch commented Feb 1, 2020

Will leave an open cursor on the transaction (as the enumeration never completes):
collection.FindById(id);

Will NOT leave an open cursor on the transaction (as the enumeration completes):
collection.Find(x => x.Id == id, skip: 0, limit: 1).ToArray().FirstOrDefault();

@clooudch
Copy link
Author

clooudch commented Feb 1, 2020

if (transaction.OpenCursors.Count > 0) throw new LiteException(0, "This thread contains an open query/cursor. Close cursors before run Commit()");

This line currently stops you from running an 'FindById' operation inside of a transaction.

@lbnascimento
Copy link
Collaborator

@clooudch Could you test it with v5.0.1?

@OrkanCom
Copy link

OrkanCom commented Feb 4, 2020

Due to my tests, I can confirm that v5.0.1 fixed the problem. Thanks.

@mbdavid mbdavid added the fixed label Feb 9, 2020
@mbdavid mbdavid closed this as completed Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants