Page 1 of 4

Unclosed connections

Posted: Sun Oct 10, 2010 9:40 am
by Naonah
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number: 4220
L2JDP Revision Number:7668

hmm, something is wrong with closed connections debugging or there is something strange.

I am sure, I have all closed connections and I have GS Console spammed with unclosed conns.

Please tell me where in this script I have unclosed connection?

http://pastebin.com/enyWQ1Uy

Thank you for you time to check this.
Best regards.

Re: Unclosed connections

Posted: Sun Oct 10, 2010 9:46 am
by Starter
lol? :mrgreen:

Re: Unclosed connections

Posted: Sun Oct 10, 2010 9:46 am
by _DS_
At least connection from line 351 not always closed.

Re: Unclosed connections

Posted: Sun Oct 10, 2010 10:03 am
by Naonah
_DS_ wrote:At least connection from line 351 not always closed.
this closing (in line 371) is not sufficient? If not, please tell where to close this damn connection :P

Thank you for your help and time.

Re: Unclosed connections

Posted: Sun Oct 10, 2010 10:04 am
by _DS_
You closed only in one branch of "if".

Re: Unclosed connections

Posted: Sun Oct 10, 2010 10:05 am
by Naonah
_DS_ wrote:You closed only in one branch of "if".
ahh, yes :P

Once again thank you :)

Re: Unclosed connections

Posted: Sun Oct 10, 2010 10:46 am
by Naonah
sry for double post but...

I have this error lol

Code: Select all

Error on: C:\Documents and Settings\bolo.LOL-805AA799D1C\Pulpit\ServerFreya\gameservertest\data\scripts\custom\buffer\__init__.py.error.logLine: -1 - Column: -1 Traceback (innermost last):  (no code object) at line 0SyntaxError: ('invalid syntax', ('__init__.py', 359, 25, '\t\t\tif buffCount == 0 : HTML_MESSAGE += "No buffs are available at this moment!<br>"')) 
http://pastebin.com/kM9zBDr7

I dont know well python and dont know what is wrong..

Thank you.

Re: Unclosed connections

Posted: Sun Oct 10, 2010 12:35 pm
by Stake
Don't close the connection that fast. You use "conn" variable's value at line 362 too. It's not a delayed-running function, so you can put the connection closing method to the end of the function.

Anyway, as I know, python doesn't support direct operators +=, -= and so on. Rather do this:

Code: Select all

HTML_MESSAGE = str(HTML_MESSAGE) + "No buffs are available at this moment!<br>"

Re: Unclosed connections

Posted: Sun Oct 10, 2010 12:58 pm
by Naonah
Stake wrote:Don't close the connection that fast. You use "conn" variable's value at line 362 too. It's not a delayed-running function, so you can put the connection closing method to the end of the function.

Anyway, as I know, python doesn't support direct operators +=, -= and so on. Rather do this:

Code: Select all

HTML_MESSAGE = str(HTML_MESSAGE) + "No buffs are available at this moment!<br>"

As you noticed I used operators +=,-= in this script many times but only in this line it throws error.

Anyway I tried like you said but still the same error. It is syntax error only but where? :)

Thank you.

Re: Unclosed connections

Posted: Sun Oct 10, 2010 1:09 pm
by Stake
Even after you removed the "try" line above of it? I mean:

Code: Select all

#try : L2DatabaseFactory.close(conn) --- no need of thisif buffCount == 0 : HTML_MESSAGE += "No buffs are available at this moment!<br>"
You should close the try condition with the except. But I said, you should remove it from that line, and insert it to the end of the function (between line 393-394) like this:

Code: Select all

try : L2DatabaseFactory.close(conn)except : pass
And delete also lines 372 and 373, where it closes db connection.

Re: Unclosed connections

Posted: Sun Oct 10, 2010 1:22 pm
by Naonah
Thank you very much for your help.

Now no errors. I will put this on live server and give a feedback here if all conections are closed :)

Re: Unclosed connections

Posted: Sun Oct 10, 2010 2:16 pm
by Naonah
Still the same...

Code: Select all

Unclosed connection! Trace: sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)java.lang.RuntimeException        at com.l2jserver.L2DatabaseFactory.getConnection(L2DatabaseFactory.java:227)        at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)        at java.lang.reflect.Method.invoke(Method.java:597)        at org.python.core.PyReflectedFunction.__call__(Unknown Source)        at org.python.core.PyMethod.__call__(Unknown Source)        at org.python.core.PyObject.__call__(Unknown Source)        at org.python.core.PyInstance.invoke(Unknown Source)        at org.python.pycode.serializable._pyx1286719552984.onAdvEvent$14(__init__.py:771)        at org.python.pycode.serializable._pyx1286719552984.call_function(__init__.py)        at org.python.core.PyTableCode.call(Unknown Source)        at org.python.core.PyTableCode.call(Unknown Source)        at org.python.core.PyTableCode.call(Unknown Source)        at org.python.core.PyFunction.__call__(Unknown Source)        at org.python.core.PyMethod.__call__(Unknown Source)        at org.python.core.PyObject.__call__(Unknown Source)        at org.python.core.PyObject._jcallexc(Unknown Source)        at org.python.core.PyObject._jcall(Unknown Source)        at org.python.proxies.main$Quest$12.onAdvEvent(Unknown Source)        at com.l2jserver.gameserver.model.quest.Quest.notifyEvent(Quest.java:447)        at com.l2jserver.gameserver.model.actor.instance.L2PcInstance.processQuestEvent(L2PcInstance.java:1822)        at com.l2jserver.gameserver.network.clientpackets.RequestBypassToServer.runImpl(RequestBypassToServer.java:221)        at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:62)        at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:973)        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)        at java.lang.Thread.run(Thread.java:619) Unclosed connection! Trace: sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)java.lang.RuntimeException        at com.l2jserver.L2DatabaseFactory.getConnection(L2DatabaseFactory.java:227)        at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)        at java.lang.reflect.Method.invoke(Method.java:597)        at org.python.core.PyReflectedFunction.__call__(Unknown Source)        at org.python.core.PyMethod.__call__(Unknown Source)        at org.python.core.PyObject.__call__(Unknown Source)        at org.python.core.PyInstance.invoke(Unknown Source)        at org.python.pycode.serializable._pyx1286719552984.viewAllSchemeBuffs$21(__init__.py:448)        at org.python.pycode.serializable._pyx1286719552984.call_function(__init__.py)        at org.python.core.PyTableCode.call(Unknown Source)        at org.python.core.PyTableCode.call(Unknown Source)        at org.python.core.PyFunction.__call__(Unknown Source)        at org.python.pycode.serializable._pyx1286719552984.onAdvEvent$14(__init__.py:802)        at org.python.pycode.serializable._pyx1286719552984.call_function(__init__.py)        at org.python.core.PyTableCode.call(Unknown Source)        at org.python.core.PyTableCode.call(Unknown Source)        at org.python.core.PyTableCode.call(Unknown Source)        at org.python.core.PyFunction.__call__(Unknown Source)        at org.python.core.PyMethod.__call__(Unknown Source)        at org.python.core.PyObject.__call__(Unknown Source)        at org.python.core.PyObject._jcallexc(Unknown Source)        at org.python.core.PyObject._jcall(Unknown Source)        at org.python.proxies.main$Quest$12.onAdvEvent(Unknown Source)        at com.l2jserver.gameserver.model.quest.Quest.notifyEvent(Quest.java:447)        at com.l2jserver.gameserver.model.actor.instance.L2PcInstance.processQuestEvent(L2PcInstance.java:1822)        at com.l2jserver.gameserver.network.clientpackets.RequestBypassToServer.runImpl(RequestBypassToServer.java:221)        at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:62)        at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:973)        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)        at java.lang.Thread.run(Thread.java:619)

Re: Unclosed connections

Posted: Sun Oct 10, 2010 4:11 pm
by Stake
In server core, a connection is allowed to be only for 60 seconds. It's the maximum timeout. "Unclosed connection" is thrown otherwise. You haven't closed some db connections properly. Always close connections when:
- you are sure, that it will not be used later
- you are not sure, but the code runs immediately, with no longer delay than runtime

These two cases are almost the same, but in the second case, insert the close() method at the end of the function code.

Re: Unclosed connections

Posted: Sun Oct 10, 2010 4:55 pm
by _DS_
Just a suggestion: instead of trying to "fix" this horrible piece of code - rewrite it properly in java.

Re: Unclosed connections

Posted: Sun Oct 10, 2010 5:02 pm
by achilless
this forum was a normal baffer! look!
it only remains to correct a couple of extra connection to the database! and all!