-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
NullReferenceException in SQLite.PreparedSqlLiteInsertCommand.ExecuteNonQuery(...) #761
Comments
Hi, It crash because the member variable "Connection" is null, on this line : Here is the call stack in your code : |
Ok, after a look in the code, i think i found the problem.
|
Hi @Kipotlov , I am getting similar exception in my project too. I am getting it in iOS and Android Xamarin project. Do you any fix for that... it seems the issue is still open and your fix is not merged yet. |
To reduce the amount of exceptions I use the following as a workaround. public int InsertOrReplace(object obj) {
db.BeginTransaction();
db.Delete(obj);
int i = db.Insert(obj);
db.Commit();
return i;
} Never the less it still throws an exception from time to time at |
Thanks a lot @COM8 I will try it out.. |
I was trying to get the BUSY exception when building this, instead i get the excpetion youre talking about. It is always the task that started the first insert that fails. Im debugging on a physical device (android) The version im using is 1.6.258-beta targetFramework="monoandroid90"> I got a repro, fails everytime! (almost)
|
Now im wrapping every call in my sqlite repo with this https://alastaircrabtree.com/implementing-the-retry-pattern-for-async-tasks-in-c/ Works very good! |
@bentmar Looks good! Works for me too. Thanks! |
Glad I found this issue, I've been getting this randomly in our logs for a while. I think @Kipotlov indeed found the problem:
Seems to me the issue would be resolved if instead of |
This addresses a race condition where a new PreparedSqliteInsertCommand object was returned in a disposed state if a second object was created and inserted into the command map during its creation. The fix always returns the item inserted into the command map.
I think this won't happen 😉 |
Hmyeah I see there's a lot of open PRs and not a lot of activity. Any reason for that @praeclarum? Not meant to be judgemental, we all have stuff to do beyond pleasing users of our unpaid open source contributions ;). It's just good to know, it would be better if there didn't need to be a fork. |
Fix to #761, preventing returning a disposed command object
@ElteHupkes Please do not fork this thing :-) Already too many of those. If I'm not being responsive to important bug fixes like this, harass me on Twitter. Sorry for the delays, and thanks for the great work! |
Heheh my thoughts exactly. I'm not so active on Twitter myself but I'll keep that in mind ;). Thanks for merging! |
This addresses a race condition where a new PreparedSqliteInsertCommand object was returned in a disposed state if a second object was created and inserted into the command map during its creation. The fix always returns the item inserted into the command map.
@praeclarum can you please tell me whether this fix is available in the version '1.6.292'? Or do I need to update to '1.7.335' to get this issue fixed? Currently I am using 1.6.292 and I am getting this randomly. Thank you. |
Description:
I'm getting from time to time if I start my app a
System.NullReferenceException: Object reference not set to an instance of an object.
I'm unable to reproduce it, but once it happens once it will occur about 2 to 3 times in a row. After that the app starts again as expected. It could be that this error is related to #530 but I'm not sure. I'm accessing the DB heavily multithreaded.
Details:
1.5.231
occurs also on1.4.118
and1.3.3
16299
10586
Stacktrace:
The text was updated successfully, but these errors were encountered: