Home » U++ Library support » U++ SQL » SQLite-insert/update in threads (please help!)
SQLite-insert/update in threads (please help!) [message #27212] |
Fri, 02 July 2010 21:24 |
Sc0rch
Messages: 99 Registered: February 2008 Location: Russia, Rubtsovsk
|
Member |
|
|
I'm getting asserts of Fetch and Execute methods, sometimes. I don't know how to avoid them, but threads are really needed.
Some info about task:
- Console application.
- Main loop of program - RPC-server, with functions for user (each of functions use SQLite database, through global SQL)
- Threads registers incoming hardware events and writes them into the SQLite database.
How can I make this task threadsafe?
Please help, two days of experiments, but I have no ideas.
I'll glad to see a little codesnippet with one safe thread.
P.S. Application crashes when I try close database by calling Close() method. Anybody know why so?
Sorry for my English,
Best regards
Anton
[Updated on: Sat, 03 July 2010 04:08] Report message to a moderator
|
|
|
|
|
|
|
Re: SQLite-insert/update in threads (please help!) [message #27235 is a reply to message #27225] |
Tue, 06 July 2010 22:21 |
Sc0rch
Messages: 99 Registered: February 2008 Location: Russia, Rubtsovsk
|
Member |
|
|
luzr wrote on Tue, 06 July 2010 14:22 |
Sc0rch wrote on Fri, 02 July 2010 22:28 | Friend suggested to use try-catch construction to control unexpected situations of external resources.
|
That is a very bad idea.
|
Don't know why bad idea, but I'm trying not use them in code at all =)
I moved all database calls to one thread (for now), and no crashes now, but app became more slow on database read =(
I'll try Mutex soon. Thank you!
[Updated on: Tue, 06 July 2010 22:23] Report message to a moderator
|
|
|
|
Re: SQLite-insert/update in threads (please help!) [message #27313 is a reply to message #27212] |
Mon, 12 July 2010 08:12 |
Sc0rch
Messages: 99 Registered: February 2008 Location: Russia, Rubtsovsk
|
Member |
|
|
I've tested the server (1000 incoming events, no delay): FAILED with Mutex =( I'm getting crashes in Execute, Fetch, GetColumnInfo methods. I've checked all functions with SQL and cursors, there are mutex in all at the start of functions. The crashes now not only from ASSERT, but sometimes even from sqlite3 funcs %)
Maybe, change the SQL engine?
[Updated on: Mon, 12 July 2010 08:14] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sat May 04 16:31:35 CEST 2024
Total time taken to generate the page: 0.02707 seconds
|