View previous topic :: View next topic |
Author |
Message |
highv priest
Joined: 01 Mar 2013 Posts: 111
|
Posted: Wed May 08, 2013 19:22 Post subject: Resetplugin disconnects sqlite |
|
|
Tested this out exhaustingly and found the cause. Whenever the server resets from the resetplugin it disconnects with sqlite... Is there a way to remedy this problem? If I manually turn off nwserver then it works fine so it's literally only that plugin.
EDIT= By disconnect I mean it deletes everything created in the database-journal instead of dumping it into the actual sqlite.db |
|
Back to top |
|
|
Terra_777
Joined: 27 Jun 2008 Posts: 216 Location: Sweden
|
Posted: Wed May 08, 2013 20:06 Post subject: |
|
|
not sure if this works for sqlite but try calling this on module load:
Code: | SetLocalString(GetModule(), "NWNX!ODBC!EXEC", "SET AUTOCOMMIT=1"); |
_________________ I dun have any signature, I'm happy anyway. |
|
Back to top |
|
|
highv priest
Joined: 01 Mar 2013 Posts: 111
|
Posted: Wed May 08, 2013 20:25 Post subject: |
|
|
Ok I'll try that and hopefully it works. I want to use SQL, but when you're only using it to store single instances of variables it appears sqlite is faster. I just need to make it permanently store it lol. |
|
Back to top |
|
|
highv priest
Joined: 01 Mar 2013 Posts: 111
|
Posted: Wed May 08, 2013 23:59 Post subject: |
|
|
It didn't work. This is the statement returned:
NWNX ODBC2 plugin V.0.9.2.5
(c) 2005 by Ingmar Stieger (Papillon) and Jeroen Broekhuizen
visit us at http://www.nwnx.org
o Logfile maximum size limit is: 524288 bytes
o Log level: Everything will be logged.
o Using SQLite connection.
o Hooking SCO....hooked at 5d5830
o Hooking RCO....hooked at 5d5710
o Connect successful.
o Got request: SET AUTOCOMMIT=1
! SQL Error: near "SET": syntax error |
|
Back to top |
|
|
highv priest
Joined: 01 Mar 2013 Posts: 111
|
Posted: Thu May 09, 2013 1:31 Post subject: |
|
|
I downloaded your system_data_2 plugin to see if the terminateprocess in it will allow my server to reset without breaking SQL connection, lol waiting for a natural reset to test it out. |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
|
Back to top |
|
|
highv priest
Joined: 01 Mar 2013 Posts: 111
|
Posted: Thu May 09, 2013 19:45 Post subject: |
|
|
It didn't work when I used Terra's system_data_2 to close it down :/. The automatic(and only automatic) reset still causes the sqlite to not dump the database-journal to the database.
EDIT= Virusman I originally did use that plugin, but it caused the binds to be lost as well. Is there something I'm missing that will make sqlite actually dump the journal files to database without me manually turning off nwserver? |
|
Back to top |
|
|
eeriegeek
Joined: 07 Jan 2008 Posts: 59
|
Posted: Fri May 10, 2013 6:11 Post subject: |
|
|
Last time I worked with the Linux sqlite db handler, it was explicitly beginning a transaction on initialization. This requires an explicit commit to avoid a rollback on shutdown. You could try issuing a COMMIT just before calling the reset plugin. Something like:
Code: |
SetLocalString(GetModule(), "NWNX!ODBC!EXEC", "COMMIT");
|
should work. It would probably be good to call COMMIT followed by a new BEGIN periodically during server operation to avoid growing really large journal files or losing data on server crashes. |
|
Back to top |
|
|
highv priest
Joined: 01 Mar 2013 Posts: 111
|
Posted: Sat May 11, 2013 2:28 Post subject: |
|
|
You sir are amazing! Thank you for the assistance. Issuing the commit right before server reset does infact work to dump the journal files into the database where they belong. You said I have to issue a BEGIN statement after issuing a commit statement. Does that mean if I issue a commit statement without issuing a BEGIN afterwards it won't write any more information? |
|
Back to top |
|
|
eeriegeek
Joined: 07 Jan 2008 Posts: 59
|
Posted: Sun May 12, 2013 3:11 Post subject: |
|
|
Hey, glad it's working. Issuing a new BEGIN just opens a new transaction, it will have to be followed at some point with another COMMIT. The sqlite plugin presumably uses transactions this way for the side effect that sets of statements in a transaction run faster. If you close the current transaction with a COMMIT and continue to run SQL statements, sqlite conveniently goes into autocommit mode and wraps each statement with a transaction as needed, but this is somewhat slower. |
|
Back to top |
|
|
|