Hi Hick,
You were right I was not finalizing statements and this prevented close
to complete. When I modified my code to finalize all statements before
close it works fine.
However I was always checking return status from sqlite_close_v2 call
and it was always 0. This is fine according to the documentation:
"If sqlite3_close_v2() is called on a database connection
<http://www.sqlite.org/c3ref/sqlite3.html> that still has outstanding
prepared statements <http://www.sqlite.org/c3ref/stmt.html>, BLOB
handles <http://www.sqlite.org/c3ref/blob.html>, and/or sqlite3_backup
<http://www.sqlite.org/c3ref/backup.html> objects then it returns
SQLITE_OK but the deallocation of resources is deferred until all
prepared statements <http://www.sqlite.org/c3ref/stmt.html>, BLOB
handles <http://www.sqlite.org/c3ref/blob.html>, and sqlite3_backup
<http://www.sqlite.org/c3ref/backup.html> objects are also destroyed."
I admit I had missed this sentence, but to be honest, it seems to be
very confusing behaviour.
Regards,
Greg
On 02/07/14 16:22, Hick Gunter wrote:
What is your sequence of calls?
What do you mean by "one connection for the application lifetime" and "others on
demand for each transaction"?
A "connection" is created/destroyed (aka opened/closed) with sqlite3_open resp.
sqlite3_close calls. This opens/closes the underlying file handles.
A "statement" is created/destroyed with sqlite3_prepare resp. sqlite3_finalize
calls. Unfinalized statements will prevent sqlite3_close from working and return an error
code.
My guess is you are not finalizing your statements and not checking
sqlite3_close return status, thus missing SQLite having a lot of open files. Is
there a lsof command or a /proc filesystem or equivalent?
-----Ursprüngliche Nachricht-----
Von: Grzegorz Sikorski [mailto:g.sikor...@kelvatek.com]
Gesendet: Mittwoch, 02. Juli 2014 13:02
An: sqlite-users@sqlite.org
Betreff: [sqlite] Problem with many connections
Hi,
I am not sure if my previous email had reached the list, so I just repeat it:
I am developing sharding database using SQLite3 for embedded application. My code works
fine up to about 1020 connections to the database. After around this number, I get an
error "unable to open database file". I double checked, permissions are OK and
I think I always properly close all connections and never open the same file twice (I
normally keep one connection opened for whole application lifetime and open others on
demand for each transaction). I found this
topic:http://stackoverflow.com/questions/22801987/sqlite3-unable-to-open-database-file-ios
and I am not sure if there is any reason why keeping opened connection in whole
application lifetime is really something I should do? I would prefer to open database
only when it is needed, to avoid risk of file corruption on power loss. Is there any
known issue with multiple open/close operations?
Regards,
Greg
--
ExchangeDefender Message Security: Click below to verify authenticity
https://admin.exchangedefender.com/verify.php?id=s62B2QLa005874&from=g.sikor...@camlintechnologies.com
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
-----------------------------------------------------------------------
Gunter Hick
Software Engineer
Scientific Games International GmbH
Klitschgasse 2 – 4, A - 1130 Vienna,
Austria
FN 157284 a, HG Wien
Tel: +43 1 80100 0
E-Mail: h...@scigames.at
This e-mail is confidential and may well also be legally privileged. If you
have received it in error, you are on notice as to its status and accordingly
please notify us immediately by reply e-mail and then
delete this message from your system. Please do not copy it or use it for any
purposes, or disclose its contents to any person as to do so could be a breach
of confidence. Thank you for your cooperation.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
--
ExchangeDefender Message Security: Click below to verify authenticity
https://admin.exchangedefender.com/verify.php?id=s62G3fnB025594&from=g.sikor...@camlintechnologies.com
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users