I have a program with multiple threads. The threads do not share the same handle.Occcasionally the program dies with a core. I see a thread always with the following stack:
#3 0x60000000d336b7c0:0 in closeDB () at ../lang/sql/generated/sqlite3.c:35553
#4 0x60000000d3388c60:0 in btreeInvalidateHandleCache ()
#5 0x60000000d3387540:0 in sqlite3BtreeBeginTrans ()
#6 0x60000000d33d2cc0:0 in sqlite3InitOne ()
#7 0x60000000d33d1b80:0 in sqlite3Init ()
#8 0x60000000d33d1770:0 in sqlite3LocateTable ()
#9 0x60000000d33cebb0:0 in selectExpander ()
#10 0x60000000d33ce780:0 in sqlite3SelectExpand ()
#11 0x60000000d33ce470:0 in sqlite3SelectPrep ()
#12 0x60000000d3444580:0 in sqlite3Select ()
#13 0x60000000d33ab080:0 in yy_reduce ()
---Type <return> to continue, or q <return> to quit---
#14 0x60000000d33a9100:0 in sqlite3Parser ()
#15 0x60000000d33a3410:0 in sqlite3RunParser ()
#16 0x60000000d33e7110:0 in sqlite3Prepare ()
#17 0x60000000d351b640:0 in sqlite3_prepare_v2 ()
This may or may not anything to do with the problem - my question why is sqlite trying to close the database ?
Thanks for your help.
Try upgrading to 5.3.21. There were several bugs fixes there that may be the cause of your problem.
If that does not work, could you post or mail me code that reproduces the problem? Also, additional debug information from the core work be useful.
Thanks for your response. I have a few followup questions :
1. The fix titled "Fixed a rare race condition that could cause a crash if two processes opened the same database at the same time" - Is it applicable only for processes or can this problem happen with multiple threads in a process each with its own DB handle.
2. I was looking at the code & I saw that the call to "btreeInvalidateHandleCache" from "sqlite3BtreeBeginTrans" has been removed. The ischema chane check is now done from the sequence code - Was this done to fix a specific problem ?
Will appreciate a response.
1. That fix could definitely be the root of your problems. It did involve multiple threads/processes opening an existing SQL database at the same time.
2. Yes, it was done to fix an issue where dropping a table could result in the process becoming deadlocked.