Page 1 of 1

Delphi 2010, SQLite3 and win xp

Posted: 26.04.2012, 18:25
by loltrol
Hello,

i have an application with Zeos 7.0.0 and latest SQLite dll (from official site). There are several threads (each with their own TZConnection and database file) that writes data approx. once per minute. There is also DBGrid with own TZReadOnlyQuery to observe data.

Everything works fine on windows 7, where i develop my application. But on windows xp sp2 after some time (not more than 1 hour) Zeos becomes completely broken. TZConnection.ExecuteDirect doesn`t insert data and when i try to open DB with TZReadOnlyQuery it fails with "SQL error logic or missing database". Interesting, all of my dbs (~15) are numb at that moment. I have also tried with 2 threads - same thing.
This problem persist with my another application...

I have only tried on 1 winxp computer, but it is the one under which i really need to make my application work. Im going to test more later.

Maybe you know what can cause this problem?

EDIT: when i add new TZConn and create a db-file after crash, it doesnt work too. Only restart helps.

Posted: 26.04.2012, 23:29
by EgonHugeist
loltrol,

did you try to write protocols? Something like this isn't known for me. But i don't know many thing about how thread-safe zeos7 actually is.

Which compiler and which revision do you use for your app?

Michael

Posted: 27.04.2012, 06:48
by loltrol
Thanks for your answer. I use Delphi 2010 Architect and Zeos 7.0.0 (have tried it with 7.0.1 also).
How to write protocols?

The problem is not in multi-threading. I have just checked it with one thread - same result. TZConnection.ExecuteDirect raises no errors. Connected property is true. Database is also leading to correct same file.

I have noticed that without "PRAGMA journal_mode=MEMORY;" application fails much faster (in few minutes).

I can create DB after problem happens in my app, but cant read or write to it.

The most annoying things in my job are the bugs which you cant track in IDE :-(

EDIT: seems journal_mode doesnt matter. I have created simple app with TZConn, TZROQ and TDBGrid. App writes data to table every 2 seconds. I will report on results...

EDIT2:
Since my test application didnt provide same error, i have installed delphi on winXP computer.
So, my app worked fine for 1 hour, but then a '10 values for 5 columns' error appeared [CheckSQLiteError proc in ZDbcSqLiteUtils.pas]. My sql command is 'INSERT INTO [STATISTIC] ([DateTime], [{776BFF81-4578-4F5F-8364-C358CC157E09}], [{548CA039-A09B-428B-87F5-857F001D263B}], [{FAB69070-172E-4000-86D0-271D6C6D586B}], [{2EB40547-3734-4217-99B0-8334DBB39150}]) VALUES (41026,60584, 28,1, 21,6, 22,0, 23,3)'. I restarted the app and set up a breakpoint. There were '.' instead of ','. Is that means that something has changed DecimalSeparator property?

EDIT3:
After some googling i have found that i should set 'Application.UpdateFormatSettings:=False'. I will try tomorrow. So, it wasnt Zeos problem, sorry for misleading. But still maybe its reaction for such thing is a little strange :-)

Posted: 27.04.2012, 18:37
by EgonHugeist
loltrol,

this is strange but could be true. The decimalseperators where changed if we need it sometimes. But i hope this is not the reason for that behavior. I think it is the reason of a broken funtion which could be result of wrong SQLite.DLL unsupported thread-safe compiled file.

So i read my first post here again and there was something missing "Zeos7 + SQLite". Im sorry for that.

Just look here http://www.sqlite.org/threadsafe.html
eventually this could be the answer.

Otherwise we've to check the sources. But i think this isn't the point here. If Zeos changes the decimalseperators, they where set back normaly . But this could fail if one function-part raises an exception. Now the changed separator is the standart seperator.

And the next execution of a generated Statement fails..

Please be sure that you use a thread-safe compiled library here before we're searching endless in the sources... Do you agree?

The UpdateFormatSettings := False call could also make trouble! Because the SQL-decimalseperators aren't the system-decimalseperators. And we need to change them to assign the floating-point values. You are warned now!

Michael

Posted: 28.04.2012, 06:44
by loltrol
That was first thing i checked: sqlite3_threadsafe() returns 1.

As far as i understood, the DecimalSeparator could be changed by system itself. UpdateFormatSettings prevents it. Application still can change it.
In initialization of my app i set DS to '.'. Now i think it rather a bad style :-\ But i dont think it was Zeos who change separator back, because it happens only on winxp. Most likely windows or its components do it.

Another thing is that DecimalSeparator isnt thread-safe. So there could be problem when CheckSQLiteError or similiar procs works at same time in different threads.

Posted: 30.04.2012, 19:12
by EgonHugeist
loltrol,

the problem you point me here is something i never realised. But IF the decimalseperators aren't thread-safe then it could become slightly difficult. Exactly on DateTime or Decimal values we need to change them. I can't say if this is right or wrong what you're writing. Have you ever worked with self constructed FormatSettings?

In my mind is the DecimalSeperator depreated since DelphiXE , why i don't know but this could be the reason. Are there eventually some reports or knowlegde-bases to read something about?

Michael