Please help fix some error

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
angkor
Posts: 99
Joined: Sat May 02, 2009 5:32 pm

Please help fix some error

Post by angkor »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision 4507:
L2JDP Revision 7803:

Who help with this error? :?
NPE After kill Antharas

Code: Select all

Exception in thread "GeneralSTPool-11" java.lang.NullPointerException        at ai.individual.Antharas$SelfDestructionOfBomber.run(Antharas.java:643)        at com.l2jserver.gameserver.ThreadPoolManager$RunnableWrapper.run(ThreadPoolManager.java:86)        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)        at java.util.concurrent.FutureTask.run(FutureTask.java:138)        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)        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:662)
And, how, where I can found this unclosed connection?

Code: Select all

Unclosed connection! Trace: sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)^Mjava.lang.RuntimeException        at com.l2jserver.L2DatabaseFactory.getConnection(L2DatabaseFactory.java:227)        at sun.reflect.GeneratedMethodAccessor24.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._pyx1298728772248.onAdvEvent$14(__init__.py:713)        at org.python.pycode.serializable._pyx1298728772248.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$424.onAdvEvent(Unknown Source)        at com.l2jserver.gameserver.model.quest.Quest.notifyEvent(Quest.java:448)        at com.l2jserver.gameserver.model.actor.instance.L2PcInstance.processQuestEvent(L2PcInstance.java:1774)        at com.l2jserver.gameserver.network.clientpackets.RequestBypassToServer.runImpl(RequestBypassToServer.java:212)        at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:62)        at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1003)        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:662)
Thank
User avatar
kimeraweb
Posts: 55
Joined: Sat Jul 31, 2010 5:33 pm
Location: Deutschland
Contact:

Re: Please help fix some error

Post by kimeraweb »

After Antharas I guess once mob called Bomber dies, it should be deleted, NPE is beacuse he is no existing.

line 615:

Code: Select all

    private class SelfDestructionOfBomber implements Runnable    {        private L2Npc _bomber;                public SelfDestructionOfBomber(L2Npc bomber)        {            _bomber = bomber;        }                public void run()        {            L2Skill skill = null;            switch (_bomber.getNpcId())            {                case 29070:                case 29071:                case 29072:                case 29073:                case 29074:                case 29075:                    skill = SkillTable.getInstance().getInfo(5097, 1);                    break;                case 29076:                    skill = SkillTable.getInstance().getInfo(5094, 1);                    break;            }                        _bomber.doCast(skill);            _selfDestructionTask.cancel(false); // line 643            _selfDestructionTask = null;        }    }
Null Pointer Exception by python... I guess using custom buffer? If it is so, close mysql connection after tasks done and open new one for new requested task to database. Don't hold them open because thread are close itself when the server is players full.
GS: 4470
DP: 7733
angkor
Posts: 99
Joined: Sat May 02, 2009 5:32 pm

Re: Please help fix some error

Post by angkor »

Thank you kimeraweb.
I use this buffer, where I do close connection?
In attachment
You do not have the required permissions to view the files attached to this post.
User avatar
kimeraweb
Posts: 55
Joined: Sat Jul 31, 2010 5:33 pm
Location: Deutschland
Contact:

Re: Please help fix some error

Post by kimeraweb »

In every mysql perform, let's see:

Code: Select all

         def buildHtml(buffType):        ...        ...        ...             getList = conn.prepareStatement("SELECT * FROM buffer_buff_list WHERE buffType=\""+buffType+"\" AND canUse=1")            rs=getList.executeQuery()            while (rs.next()) :                try : buffCount += 1                except : buffCount = 0                        # Here Close connection -------------------------------------------->*<--            L2DatabaseFactory.close(conn)            # Anyway mysql will do it itself             if buffCount == 0 : HTML_MESSAGE += "No buffs are available at this moment!<br>"            else :                availableBuffs = []                                # Here, request connection again --------------------------------------->*<--                conn=L2DatabaseFactory.getInstance().getConnection()                 getList = conn.prepareStatement("SELECT buffId,buffLevel FROM buffer_buff_list WHERE buffType=\""+buffType+"\" AND canUse=1  ORDER BY Buff_Class ASC, id")                rs=getList.executeQuery()                while (rs.next()) :                    try :                        bId = rs.getInt("buffId")                        bLevel = rs.getInt("buffLevel")                        bName = SkillTable.getInstance().getInfo(bId,bLevel).getName()                        bName = bName.replace(" ","+")                        availableBuffs += [bName+"_"+str(bId)+"_"+str(bLevel)]                    except: HTML_MESSAGE += "Error loading buff list...<br>"                try : L2DatabaseFactory.close(conn)                except : pass 
and this block is very slow to run:

Code: Select all

        if event == "cast" :            if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime") :                buffs = []; levels = []; id = 0; level = 0                conn=L2DatabaseFactory.getInstance().getConnection()                rss = conn.prepareStatement("SELECT * FROM buffer_scheme_contents WHERE scheme_id="+eventParam1+" ORDER BY id")                action=rss.executeQuery()                while (action.next()) :                    try :                        enabled = 1                        id = int(action.getString("skill_id"))                        level = int(action.getString("skill_level"))                        skillType = getBuffType(id)                        if skillType == "buff" :                            if ENABLE_BUFFS == True :                                if isEnabled(id,level) == "True" :                                     buffs += [id]                                    levels += [level]                        if skillType == "resist" :                            if ENABLE_RESIST == True :                                if isEnabled(id,level) == "True" :                                    buffs += [id]                                    levels += [level]                        if skillType == "song" :                            if ENABLE_SONGS == True :                                if isEnabled(id,level) == "True" :                                    buffs += [id]                                    levels += [level]                        if skillType == "dance" :                            if ENABLE_DANCES == True :                                if isEnabled(id,level) == "True" :                                    buffs += [id]                                    levels += [level]                        if skillType == "chant" :                            if ENABLE_CHANTS == True :                                if isEnabled(id,level) == "True" :                                    buffs += [id]                                    levels += [level]                        if skillType == "overlord" :                            if ENABLE_OL == True :                                if isEnabled(id,level) == "True" :                                    buffs += [id]                                    levels += [level]                        if skillType == "others" :                            if ENABLE_OTHERS == True :                                if isEnabled(id,level) == "True" :                                    buffs += [id]                                    levels += [level]                        if skillType == "special" :                            if ENABLE_SPECIAL == True :                                if isEnabled(id,level) == "True" :                                    buffs += [id]                                    levels += [level]                    except : print "Query error!"                try : L2DatabaseFactory.close(conn)                except : pass
So many checking... it is up mysql load, if these checks get more time it should, mysql can close connection here by itself, my suguestion. But code is good.

This is all what I get in my first eye.

I have to add, so many querys turn your perforance server slower, because access to the disk is slower than access to memory, one query takes more or less 300ms if it is prepared statement.

You can check it out yourself with this code I made to check mysql perforance:

Code: Select all

 /**  *  @author Kimera  */     import java.sql.DriverManager;   import java.sql.PreparedStatement;   import java.sql.ResultSet;   import java.sql.SQLException;   import java.util.Date;     import com.mysql.jdbc.Connection;   import com.mysql.jdbc.Statement;       public class Main {              public static void main (String [] arg) throws ClassNotFoundException, SQLException       {           long ahora = cronometro(0, 0);           queryConPreparedStatement();           long tiempo = cronometro(1,ahora);           System.out.println("Query en " + tiempo);                      long ahora1 = cronometro(0, 0);           queryConPreparedStatement();           long tiempo1 = cronometro(1,ahora1);           System.out.println("Query en " + tiempo1);                      long ahora2 = cronometro(0, 0);           queryConResultSet();           long tiempo2 = cronometro(1,ahora2);           System.out.println("Query en " + tiempo2);       }                     public static void queryConPreparedStatement() throws ClassNotFoundException, SQLException       {            Class.forName(Datos.Driver.getData());                       Connection c = (Connection) DriverManager.getConnection(Datos.UrlBaseDatos.getData(),Datos.LoginMySql.getData(),Datos.PasswordMySql.getData());                        PreparedStatement ps = (PreparedStatement) c.prepareStatement("Select * from characters where online=?");            ps.setInt(1,0);                      ResultSet rs;                      rs = ps.executeQuery();                      int PJs_offline=0;           while (rs.next())           {               PJs_offline++;           }           System.out.println("Hay " + PJs_offline + " PJs desconectados.");           ps.close();       }              public static void queryConResultSet() throws ClassNotFoundException, SQLException       {           // Load driver           Class.forName(Datos.Driver.getData());           // Connectio         Connection cn = (Connection) DriverManager.getConnection(Datos.UrlBaseDatos.getData(),Datos.LoginMySql.getData(),Datos.PasswordMySql.getData());                      // Statement        Statement st = (Statement) cn.createStatement();                      // Resulset         ResultSet rs = st.executeQuery("Select * from characters where online=0");                      // ResultSet        int PJs_offline = 0;                      while(rs.next())           {               PJs_offline++;           }                      // Saving up resources        rs.close();                      // Showing query           System.out.println("Hay " + PJs_offline + " PJs desconectados.");       }              /**       * opcion, tiempo<br>       * <li>opcion 1, devuelve la fecha</li>       * <li>opcion 2, devuelve la resta</li>       *       */       public static long cronometro(int opcion, long tiempo)       {           Date t = new Date();           long fecha = t.getTime(), resultado=0;                      switch (opcion)           {           case 0:               resultado = fecha;               break;             case 1:               resultado = fecha-tiempo;               break;             }                      return resultado;       }              /**       * MySQL Connections     */       enum Datos       {           Driver("com.mysql.jdbc.Driver"),           UrlBaseDatos("jdbc:mysql://localhost/l2jdb"),           LoginMySql("root"),           PasswordMySql("");                      String contenido;                      // Constructor        Datos(String text)           {               contenido = text;           }                      String getData()           {               return contenido;           }             }     }   
I hope be useful.
GS: 4470
DP: 7733
angkor
Posts: 99
Joined: Sat May 02, 2009 5:32 pm

Re: Please help fix some error

Post by angkor »

Maybe you help optimize my mysql server config?
I have Intel Xeon 5460 Processor, 8 Gb DDR2, 15k SAS 73gb

and my.cfg

Code: Select all

#skip-external-lockingkey_buffer              = 256Mmax_allowed_packet      = 16Mthread_stack            = 256Kthread_cache_size       = 16max_connections        = 700table_cache            = 2048thread_concurrency     = 8query_cache_limit       = 128Mquery_cache_size        = 512Mlog_error                = /var/log/mysql/error.logdefault-storage-engine=INNODBinnodb_buffer_pool_size = 1Ginnodb_additional_mem_pool_size = 10Minnodb_file_io_threads = 8innodb_thread_concurrency = 16innodb_log_buffer_size = 16Minnodb_log_file_size = 256Minnodb_data_file_path = ibdata1:512M:autoextendmemlock[mysqldump]quickquote-namesmax_allowed_packet      = 32M[mysql][isamchk]# key_buffer            = 32M# !includedir /etc/mysql/conf.d/ 
User avatar
kimeraweb
Posts: 55
Joined: Sat Jul 31, 2010 5:33 pm
Location: Deutschland
Contact:

Re: Please help fix some error

Post by kimeraweb »

I'm afraid not enough skilled with it.

I only can say, if your cpu is not very busy, you can try raise max connections allowed.

Care, if you set up too much, you will hold the server.

Cache is important for performance because, if query is repeated, results are token from cache, saving up resources and time.

And I got this from this forum time ago, I don't remember a link but, I paste it here for you:

Code: Select all

# MySQL Server Instance Configuration File# ----------------------------------------------------------------------# Generated by the MySQL Server Instance Configuration Wizard### Installation Instructions# ----------------------------------------------------------------------## On Linux you can copy this file to /etc/my.cnf to set global options,# mysql-data-dir/my.cnf to set server-specific options# (@localstatedir@ for this installation) or to# ~/.my.cnf to set user-specific options.## On Windows you should keep this file in the installation directory # of your server (e.g. C:\Program Files\MySQL\MySQL Server 4.1). To# make sure the server reads the config file use the startup option # "--defaults-file". ## To run run the server from the command line, execute this in a # command line shell, e.g.# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 4.1\my.ini"## To install the server as a Windows service manually, execute this in a # command line shell, e.g.# mysqld --install MySQL41 --defaults-file="C:\Program Files\MySQL\MySQL Server 4.1\my.ini"## And then execute this in a command line shell to start the server, e.g.# net start MySQL41### Guildlines for editing this file# ----------------------------------------------------------------------## In this file, you can use all long options that the program supports.# If you want to know the options a program supports, start the program# with the "--help" option.## More detailed information about the individual options can also be# found in the manual.### CLIENT SECTION# ----------------------------------------------------------------------## The following options will be read by MySQL client applications.# Note that only client applications shipped by MySQL are guaranteed# to read this section. If you want your own MySQL client program to# honor these values, you need to specify it as an option during the# MySQL client library initialization.#[client] port=3306 [mysql] default-character-set=latin1  # SERVER SECTION# ----------------------------------------------------------------------## The following options will be read by the MySQL Server. Make sure that# you have installed the server correctly (see above) so it reads this # file.#[mysqld] # The TCP/IP Port the MySQL Server will listen onport=3306  #Path to installation directory. All paths are usually resolved relative to this.basedir="D:/MySQL Server/" #Path to the database rootdatadir="D:/MySQL Server/Data/" # The default character set that will be used when a new schema or table is# created and no character set is defineddefault-character-set=latin1 # The default storage engine that will be used when create new tables whendefault-storage-engine=INNODB  # The maximum amount of concurrent sessions the MySQL server will# allow. One of these connections will be reserved for a user with# SUPER privileges to allow the administrator to login even if the# connection limit has been reached.max_connections=2047 # Query cache is used to cache SELECT results and later return them# without actual executing the same query once again. Having the query# cache enabled may result in significant speed improvements, if your# have a lot of identical queries and rarely changing tables. See the# "Qcache_lowmem_prunes" status variable to check if the current value# is high enough for your load.# Note: In case your tables change very often or if your queries are# textually different every time, the query cache may result in a# slowdown instead of a performance improvement.query_cache_size=0k # The number of open tables for all threads. Increasing this value# increases the number of file descriptors that mysqld requires.# Therefore you have to make sure to set the amount of open files# allowed to at least 4096 in the variable "open-files-limit" in# section [mysqld_safe]table_cache=4100 # Maximum size for internal (in-memory) temporary tables. If a table# grows larger than this value, it is automatically converted to disk# based table This limitation is for a single table. There can be many# of them.tmp_table_size=16M  # How many threads we should keep in a cache for reuse. When a client# disconnects, the client's threads are put in the cache if there aren't# more than thread_cache_size threads from before.  This greatly reduces# the amount of thread creations needed if you have a lot of new# connections. (Normally this doesn't give a notable performance# improvement if you have a good thread implementation.)thread_cache_size=64 #*** MyISAM Specific options # The maximum size of the temporary file MySQL is allowed to use while# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.# If the file-size would be bigger than this, the index will be created# through the key cache (which is slower).myisam_max_sort_file_size=100G # If the temporary file used for fast index creation would be bigger# than using the key cache by the amount specified here, then prefer the# key cache method.  This is mainly used to force long character keys in# large tables to use the slower key cache method to create the index.myisam_max_extra_sort_file_size=100G # If the temporary file used for fast index creation would be bigger# than using the key cache by the amount specified here, then prefer the# key cache method.  This is mainly used to force long character keys in# large tables to use the slower key cache method to create the index.myisam_sort_buffer_size=8M # Size of the Key Buffer, used to cache index blocks for MyISAM tables.# Do not set it larger than 30% of your available memory, as some memory# is also required by the OS to cache rows. Even if you're not using# MyISAM tables, you should still set it to 8-64M as it will also be# used for internal temporary disk tables.key_buffer_size=73M # Size of the buffer used for doing full table scans of MyISAM tables.# Allocated per thread, if a full scan is needed.read_buffer_size=64Kread_rnd_buffer_size=256K # This buffer is allocated when MySQL needs to rebuild the index in# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE# into an empty table. It is allocated per thread so be careful with# large settings.sort_buffer_size=208K  #*** INNODB Specific options ***  # Use this option if you have a MySQL server with InnoDB support enabled# but you do not plan to use it. This will save memory and disk space# and speed up some things.#skip-innodb # Additional memory pool that is used by InnoDB to store metadata# information.  If InnoDB requires more memory for this purpose it will# start to allocate it from the OS.  As this is fast enough on most# recent operating systems, you normally do not need to change this# value. SHOW INNODB STATUS will display the current amount used.innodb_additional_mem_pool_size=8M # If set to 1, InnoDB will flush (fsync) the transaction logs to the# disk at each commit, which offers full ACID behavior. If you are# willing to compromise this safety, and you are running small# transactions, you may set this to 0 or 2 to reduce disk I/O to the# logs. Value 0 means that the log is only written to the log file and# the log file flushed to disk approximately once per second. Value 2# means the log is written to the log file at each commit, but the log# file is only flushed to disk approximately once per second.innodb_flush_log_at_trx_commit=1 # The size of the buffer InnoDB uses for buffering log data. As soon as# it is full, InnoDB will have to flush it to disk. As it is flushed# once per second anyway, it does not make sense to have it very large# (even with long transactions).innodb_log_buffer_size=1459K # InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and# row data. The bigger you set this the less disk I/O is needed to# access data in tables. On a dedicated database server you may set this# parameter up to 80% of the machine physical memory size. Do not set it# too large, though, because competition of the physical memory may# cause paging in the operating system.  Note that on 32bit systems you# might be limited to 2-3.5G of user level memory per process, so do not# set it too high.innodb_buffer_pool_size=200M # Size of each log file in a log group. You should set the combined size# of log files to about 25%-100% of your buffer pool size to avoid# unneeded buffer pool flush activity on log file overwrite. However,# note that a larger logfile size will increase the time needed for the# recovery process.innodb_log_file_size=72M # Number of threads allowed inside the InnoDB kernel. The optimal value# depends highly on the application, hardware as well as the OS# scheduler properties. A too high value may lead to thread thrashing.innodb_thread_concurrency=8#Lock mysqld in memory.(=Don't swap.)memlock 
GS: 4470
DP: 7733
angkor
Posts: 99
Joined: Sat May 02, 2009 5:32 pm

Re: Please help fix some error

Post by angkor »

Thank you for you work. You helped me a lot
User avatar
kimeraweb
Posts: 55
Joined: Sat Jul 31, 2010 5:33 pm
Location: Deutschland
Contact:

Re: Please help fix some error

Post by kimeraweb »

My pleasure :)
GS: 4470
DP: 7733
Post Reply