开发者

Hibernate spring hangs

I'm working on an hibernate Spring Mysql app, sometimes when i make a gethibernateTemplate()get(class,id) i can see a bunch of HQL in the logs and the application hangs, have to kill tomcat. This method reads trhough a 3,000 lines file, and there should be 18 files of these, i've been thinking i probably been looking at this wrong. I need you to help me check this at database level , but i don´t know hot to approach. Maybe my database can´t take so many hits so fast.

I´v looked in phpMyAdmin in the information bout executions time section, i see a red values in:

Innodb_buffer_pool_reads 165 Handler_read_rnd 40 Handler_read_rnd_next 713 k Created_tmp_disk_tables 8 Opened_tables 30

Can i set the application some how to threat more gently the database ? How can i check if this is the issue ?

Update I put a

Thread.sleep(2000);

at the end of each cycle and it made the same numbers of calls (18), so i guess this wont be te reason ? can i discard this approach ? This is a different view of this question

Hibernate hangs or throws lazy initialization no session or session was closed

trying some different

Update 2

Think it might be the buffer reader reading the file?? file is 4开发者_高级运维4KB, tried this method:

http://code.hammerpig.com/how-to-read-really-large-files-in-java.html

class but did not work.


Update 1 -- do never use a Sleep or something slow within an transaction. A transaction has to be closed as fast as possible, because it can block other database operations (what exactly will be blocked depends on the isolation level)


I do not really understand how the database is related to the files in your usecase. But if the stuff works for the first file and become slow later on, then the problem can be the Hibernate Session (to many objects), in this case start an new Transaction/Hibernate Session for each file.


I rewrote the program so i load the information directly into the database using mysql query LOAD DATA INFILE. It works very fast. Then i updated rows changing some fields i need also with sql queries. I think there is simply too much information at the same time to manage trhough memory and abstractions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜