ShokoAnime / ShokoServer

Repository for Shoko Server.
https://shokoanime.com/
MIT License
404 stars 74 forks source link

JMM Server 100% CPU #74

Closed jmediamanager closed 9 years ago

jmediamanager commented 10 years ago

Reported by misakitchi, Apr 19, 2014

What steps will reproduce the problem?

  1. I launch JMM server: all is good
  2. After 5-6 minutes JMM Server will suddenly use almost 100% CPU!!

What version of the product are you using? On what operating system? JMM Server 3.1.32 + SQL2008 Windows 7 64bits (French)

Please provide any additional information below. If i go back to JMM Server 3.1.17, i have not this problem JMM Desktop is not launched i try with MySQL and SQLite and same issue...

misakitchi commented 10 years ago

I try 3.4.1.0 Beta and the problem is still there :( Can you release versions between 3.1.17 and 3.1.32 with changelog, so that i can see which works and what new feature do the bug? Thanks!

jmediamanager commented 10 years ago

Can you also attach your logs?

If you want to try out previous versions, see the following archives http://jmm.hobbydb.net.leaf.arvixe.com/jmmserver/ http://jmm.hobbydb.net.leaf.arvixe.com/jmmdesktop/

Look for the files named like this jmmdesktop.all.to.3.1.18.zip

They contain the full binaries

misakitchi commented 10 years ago

Thanks!! OK i have tried all thoses builds and the bug appear at v3.1.26

JMMServer v3.1.17 OK JMMServer v3.1.18 OK JMMServer v3.1.19 OK JMMServer v3.1.21 OK JMMServer v3.1.22 OK JMMServer v3.1.23 OK JMMServer v3.1.24 OK JMMServer v3.1.25 OK JMMServer v3.1.26 Bug! JMMServer v3.1.27 Bug JMMServer v3.1.28 Bug JMMServer v3.1.29 Bug JMMServer v3.1.31 Bug JMMServer v3.1.32 Bug!

Do you have the changelog of this build? I will try to add logs too

misakitchi commented 10 years ago

I have logs but i can't add it in comment... How i can do that?

CuddleBear92 commented 10 years ago

you need to upload the logs somewhere. make a Mega, OneDrive, Dropbox folder or you can use pastebin if you are going to share only one file. i feel Mega is the better choice tho, but i have no idea what the admin likes here XD example of Mega folder and link to site: https://mega.co.nz/#F!JsJxUKQD!kaUdPc5vx_yUZ0nxidsrSQ

misakitchi commented 10 years ago

OK thanks! Its the logs for v3.1.26 which is bugging: https://mega.co.nz/#!bAdjTKiT!9v0nAtcVsOY_MPUqlnXRUAodMuO1-uHlnsGOTYnvLCQ

jmediamanager commented 10 years ago

Does it still use 100% CPU if you haven't added any files?

misakitchi commented 9 years ago

OK I have done a Fresh New Install with Beta 3.4.2.1 I have not this bug anymore, but must rehash all my anime... more than 10To :( Is there a way to get my old custom Collections "Group Filters"?

jmediamanager commented 9 years ago

Sorry the group filters are not stored in the web cache. Did you happen to keep your old database?

misakitchi commented 9 years ago

Yes I delete nothing! I have create a full new install of JMM server with a new database (JMMServerBeta)

But i have keep the old server and old database (JMMServer) I open the old database with "SQL Server Management Studio" but i m not so skilled to understand it... :( But if you say me where i can extract the "Collection Group Filters" i can do it :)

CuddleBear92 commented 9 years ago

not to be rude or anything, but do you have that many filters? i mean it takes me like a few min to create like 50 filters if i find a reason to create so many.

if there really isnt that many, why not just create new once?

misakitchi commented 9 years ago

I create about 20 group filters but i take long time to do it, so if i can export them from old base its faster :)

CuddleBear92 commented 9 years ago

faster than waiting for an anwser here? really? i bet you can make new once in about 15 min even if you are not that familiar with the system. you have used more time on here asking about it than what it would take to create new once.

one the side of Filters, it would be great if we could export and share the filters with people, make them exportable to a text format or something that we can share here and other places. that might be a good way to find out what people are using and give people an overview, you could host these at your server host aswell as small txt formats like that should not take much space.... then again, will it really be needed. atleast exporting and importing filters can be good for the community and sharing IMO.

misakitchi commented 9 years ago

I m kind of lazy guy lol! :)

Yes import/export filters is a good idea :)

misakitchi commented 9 years ago

So did you have a way to export "Group Filters" or i do it again? :santa:

jmediamanager commented 9 years ago

Are you using SQL Server? That's what I seem to remember. I should be able to create a SQL script to move the group filters over

jmediamanager commented 9 years ago

Actually that will be too hard. Let me write up a guide on how to do it, via SQL Mangement Studio

misakitchi commented 9 years ago

OK i will do my filters again no pb :)

jmediamanager commented 9 years ago

Sorry I meant I will do a guide on how to transfer your filters over. You can use Management Studio

jmediamanager commented 9 years ago

http://japanesemediamanager.github.io/wiki_usermanual_sqlserver.html

misakitchi commented 9 years ago

Thx! It was a little hard but it works! ^_^

Just few things in your tutorial:

And the Migration erase the new group filters in the NEW Database xD Hopefully i only create one xD

But really thanks for your tuto ^_^

jmediamanager commented 9 years ago

Yeah the details will depend on what version you are using. I will adjust the tutorial a bit.

Let me know how it goes.

I also recommend installing the 64bit version of Windows for your new laptop.

misakitchi commented 9 years ago

The High CPU Bug is back!

I have installed JMM the 2014.11.06 and the bug is back the 2014.12.07 so its just 1 month after install!

12h22 JMM start 12h29 JMM CPU Bug! :'(

jmm server cpu bug 1b jmm server cpu bug 2a

Memory: 760000Ko With commands: 60-70% CPU (With commands in queue) Idle: 50% CPU (I clear the queue)

After few minutes memory explosed at 2Go and CPU is at 80%!!!

In Process Explorer: Threads: clr.dll!GetMetaDataInternalInterface+0x1de7c use 40% CPU

TEST: J-2 => I change the date of my PC J-2 (2014.12.07 => 2014.12.05)

12h53 JMM Start 13h15 I wait about 20min and still no Bug, all is OK!

jmm server cpu bug 5b no bug jmm server cpu bug 6a no bug

Memory: 217000Ko With commands: 0-1% CPU (With commands in queue) Idle: 0% CPU (I clear the queue)

To remember you the bug start with version v3.1.26 JMMServer v3.1.25 OK Hash:OK! JMMServer v3.1.26 CPU Bug!

So i think it must be some code for date, or something like it, who do the bug

misakitchi commented 9 years ago

Happy Christmas!

So nobody to help me?! :'(

jmediamanager commented 9 years ago

Sorry misakitchi, I will come back to this issue soon Have been flat out lately

misakitchi commented 9 years ago

I reinstall JMM Server v3.4.2.19 with SQLite I have no 100% CPU bug But its so SLOW and it use now more the CPU than with MSSQL...

Perhaps there is a bug with NLog, i find this page: https://github.com/NLog/NLog/issues/162 It seems there is a bug with Nlog v2.0 So can you update nlog to v3.0?

Thanks :)

jmediamanager commented 9 years ago

I can try that, for now can you try setting your logging to async?

misakitchi commented 9 years ago

In JMMServer.exe.Config I change

'targets' to 'targets async="true"'

But no change... always CPU bug...

I m trying JMM server with MySQL and no bug so perhaps its good, but i must wait one month to see if the bug come or not

With MSSQL the bug appear after one month exactly!? If i change the computer date to one day before, no bug... so i think this bug have to do something with the date...

misakitchi commented 9 years ago

Part 1: Ok so one month later... I have the same bug with MySQL: JMM is in idle state (no queue) and use lots of CPU (50%average) And i have same bug with SQLite but less CPU

So to recap: (in idle) MSSQL 50% CPU MySQL 50% CPU SQLite 25% CPU So its not the Database software who is bugging but its JMM Server... I have no problem the first 31 days and the day after CPU Bug...

Part 2: I see that with SQLite, in database folder, each seconds there is a file who appear and disappear right after! (JMMServer.db3-journal)

I make a copy, i put link th this file https://mega.co.nz/#!mMkUgaJa!6N1kN3zRmbS8SRhOfnU27o9bTgyoHpagrppqpp7AEhw

If we open it we can see: A n i D B U D P U D P R E S P O N S E T R U N C i n 1 0 9 1 , 0 6 2 4 m s - 2 2 0 ¯þ‚ƒŽ: 1ƒEYA n i D B U D P U D P C O M M A N D : F I L E s i z e = 5 0 0 7 9 9 8 0 8 & e d 2 k = 3 7ˆƒŽ= 1YA n i D B U D P U D P R E S P O N S E T R U N C i n 4 3 2 , 0 2 4 7 m s - 2 2 0 F û.…í2 1mYA n i D B U D P U D P R E S P O N S E i n 2 4 4 , 0 1 3 9 m s - 2 0 0 h n v C i L O G I N A C C E P T E D 2 0 1 5 - 0 4 - 0 2 2 0 : 1 9 : 2 8 ‚…í3 1ƒEYA n i D B U D P U D P _ C O M M A N D : F I L E s i z e = 1 6 1 7 1 6 1 3 9 & e d 2 k = 1 3 0 E 8 2 7 9 6 D D 9 2 7 7 3 3 B C 9 2 6 7 5 7 C F 0 4 E 2 8 & f m a s k = 7 F F 8 F F F 9 F E & a m a s k = 0 0 0 0 F C C 0 & s = h n v C i 2 0 1 5 - 0 4 - 0 2 2 0 : 1 9 : 3 0 ¶ÞbS SQLite format 3

Its an API request to AniBD i think, i m not specialist...

Part 3: To remember this bug appear when i go from v3.1.25 to v3.1.26 So i look at the full changelog of JMM Server: https://code.google.com/p/jmm/wiki/JMM_Alpha_Test#Version_3.1.26_%28December_21_2012%29

Version 3.1.26 (December 21 2012) Make sure that the 'Remove Missing Files' utility also updates the user's AniDB MyList Issue #138 : Option for JMM Server to change state to deleted rather than removing files from MyList when deleted from HDD Cache some AniDB info for use during file imports to prevent chances of a ban Log all API calls to AniDB into a new database table for debugging when a ban occurs Issue #352 : Slightly off-resolution files will now be grouped together, e.g. 1272x720 will be shown in same group as 1280x720 Issue #176 : Empty folders are deleted from the drop folder automatically Issue #359 : Subtitle files are now moved from drop folder along with video file File Renamer - test that Video Resolution info exists now works - I(res) Fix to make sure duplicate files entries where the file name is actually the same are removed

I think a little about it and i had few ideas, I think its:

OK it was a little long... but right now i can't use JMM anymore because of this bug... :( Since 2 months ago i can still use v3.1.25 but since the change in AniDB API i can't use it... and version > to v3.1.26 is bugging... :( So i don't know what to do, JMM is really good but if i can't use it...

Please HELP!!! :)

misakitchi commented 9 years ago

Hello! I don't know how and why but now, must of the time i don't have this CPU bug anymore! :) Last week-end i go out on holidays and forgot to close JMMserver and my computer... so for 2-3 days JMM was running, and when i come back JMM was not bugging (100% CPU bug)!! And now its OK! Sometimes i have the bug, don't know why, but on 10 launch of JMM i have about 8 OK and 2 CPU bug. (Sorry i don't know how to explain it in english, my english is very poor...) So i m very happy :)

Andy2244 commented 9 years ago

I just moved my old Media PC from a Win7 to a Win10 RTM machine and now for the first time i have this bug too.

JMMServer starts and does its import job, than it idles a few minutes at 0% with no MySQL usage and suddenly JMMServer.exe is using one core at 100% until i stop it, while doing nothing in the queue or any MySQl activity?

jmmserver bug

PS: I'm on Win10 RTM x64, with JMM 3.4.3.2 and MySql 5.6

CuddleBear92 commented 9 years ago

i also failed to inform about usage aswell over the months. my JMM server is constantly using 10-15% of my CPU (a 3960-X @ 4.2Ghz) (alot for that CPU really when you think about the power it has)

this isnt an issue on server start, but quickly starting using load for no reason at all it seems within an hour. the server can be idle with no jobs on queue at all, heck even without a client running (except the Plex Plugin).

if this is even an larger problem in Win10 then it needs to be fixed. they are giving us Win10 for free for almost anyone so ALOT of users will update, me included. (atleast when you get Win10 support it will support the phones and tablets smoother aswell at the same time)

Andy2244 commented 9 years ago

Here is the log that might help:

https://drive.google.com/file/d/0B-4v-tWdPLgCOEZQa2lQZjA4TVE/view?usp=sharing

Between 22:47 and 22:52 all is nice and nothing to-do and 0% CPU, than the last entry will use 100% CPU time.

Update: I just noticed that after my last run it now is back at 0% CPU, so maybe "CommandRequest_SyncMyList.ProcessCommand Processing CommandRequest_SyncMyList" just takes a very long time and i always aborted it? How long should this command take for a fairly large AniDB collection?

PS: It also seems anidb.net is actually down right now, maybe thats the reason for the 100% CPU or why i'm now back to 0%... Will test tomorrow again.

misakitchi commented 9 years ago

So it seems that lots of people have this CPU Bug (lots of CPU used for nothing)!!!

For people with new CPU like 3960-X @ 4.2Ghz its only 10-15% CPU, but for me with old CPU E5300@2.6GHz its 100% CPU!!! :(

Like it said previously, did this bug appear at JMMServer v3.1.26 for you too?!!

And i was thinking to upgrade from Windows 7 to Windows 8.1 or 10 only to remove this bug lol! But if the bug is here too... :(

I found lots of .NET and CPU Bug, but here some pages: http://stackoverflow.com/questions/14954387/net-4-constantly-wasting-one-cpu-core-on-strongnamesignatureverification http://stackoverflow.com/questions/13378213/visual-studio-profiler-clr-dll Don't know if thoses pages can help because i have no skills in development... :(

Please Help! Its not only me who have this bug anymore!!!

PS: i said previously that the bug have disappear... but he come back, don't know why... :(

misakitchi commented 9 years ago

I find a way to MANUALLY remove this CPU bug, but its a pain in the ass... (don't know if the right english expression lol)

I use Process Explorer and do a suspend(/resume) on threads who are bugging of JMMServer...

Here i explain more in detail: 1) Open Process Explorer and go in threads tab of JMMServer 2) Thread are sorted by CPU by default, good, so select the first thread (it must be the thread who use the most CPU...) 3) Clic on "Suspend" button and watch your JMMServer window/process: If it is freezing (its not instantaneous! it take 0 to 30 sec to be sure JMM is OK), its not good => clic on "Resume" (its the same button, it just change the name...) 4) Wait suspend button appear and repeat 3) until JMMServer is not freezing (Suspend/Resume) 5) Repeat 2) to 4) for the next threads who have CPU bug (use lots of cpu)!!

So you can see that this method is really manual and not good... And I don't really know why its working lol! xD

We really need i clean solution/patch

Thanks!

misakitchi commented 9 years ago

Here some pictures: jmmserver cpu bug - perf graph First peak is at 10:42, then 10:47, 10:52, 10:57, 11:02, 11:07... every 5 min It use lots of Memory too: 1.8GB!!!

misakitchi commented 9 years ago

I create a Straw Poll to know how many people have this bug too: http://strawpoll.me/4955543/

JMMServer must be in Idle: no queue (Hasher=0 General=0 Images=0) and JMMDesktop closed

You can use "Process Explorer" and watch in tab "Performance Graph"

Thx for help!

misakitchi commented 9 years ago

In my research on the net i find a way to force JMMServer to be in 32bit using CorFlags.exe I m not sure but it seems to use less memory...

Sources: https://lostechies.com/gabrielschenker/2009/10/21/force-net-application-to-run-in-32bit-process-on-64bit-os/ https://msdn.microsoft.com/fr-fr/library/ms164699(v=vs.110).aspx

You can find CorFlags.exe here: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64 Put CorFlags.exe in same folder that JMMServer.exe

Open cmd window (command line) Go in JMMServer folder and put this command line: CorFlags jmmserver.exe /32BIT+

Et Voila!

PS: Sorry to "Remuer Terre et Ciel!!" ("to leave no stone unturned" not sure of traduction) as we say in French!! But its really a annoying issue! :(

Andy2244 commented 9 years ago

Oki, i can not reproduce this bug anymore, either it was a one time occurrence of a operation that simply took very long on my old machine or it has to-do with a routing problem on my side, since i cant reach aniDB.net atm without using a VPN.

CuddleBear92 commented 9 years ago

i for one would not say that 1.6GB of RAM usage is alot at all really, but the server should lower its usage over time. it doesnt need to have everything in the ram at all time TBH.

also, quick question, i see there is alot of detail in that property picture.... what application is that anyway? can really come in handy for me i think.

misakitchi commented 9 years ago

Which application? "JMMServer.exe:4956 Properties"? Its "Process Explorer": i was thinking that everybody know this tool... https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

You can take the whole pack tools: "Sysinternals Tools" https://technet.microsoft.com/en-us/sysinternals/bb842062

Very usefull tools! :)

CuddleBear92 commented 9 years ago

thanks, didnt know about these at all TBH...... always used what windows gave me XD

misakitchi commented 9 years ago

AFTER MORE THAN ONE YEAR (16 MONTHS!) I FIND HOW TO REMOVE THE CPU BUG!!!!!

I m so Happy! :) Thoses days i see that a request in SQL was causing the CPU BUG When i remove it from SQL, the CPU bug was gone, but 5 min after that, the same request appear... So i try lots of options in SQL Server and find one who remove bug! :)

Go in SQL Server Management Studio Then Properties of Server, Connexions, and tick "Use query governor to prevent long-running queries" (I put 120s)

jmmserver - cpu bug - sql

Et Voila! ^_^

misakitchi commented 9 years ago

For jmediamanager, the detail of the SQL request who is doing the bug:

In SQL Activity Monitor: "Process" Tab: the query detail who is bugging: (@p0 int)DELETE FROM [LogMessage] WHERE LogMessageID = @p0

"Long queries" Tab: SELECT this_.LogMessageID as LogMessa1_1930, this_.LogType as LogType1930, this_.LogContent as LogContent1930, this_.LogDate as LogDate1930 FROM [LogMessage] this ORDER BY this.LogDate desc => Average Time was very high!

Sorry i don't have screens... but if you want i can do it

jmediamanager commented 9 years ago

Hi @misakitchi, I don't recommend changing that SQL setting. Probably the best thing to do is delete all the rows from the log message table, which should speed up any queries.

delete from LogMessage

Before you do that, can you run a query to see how many rows you current have

select count(*) from LogMessage

I noticed a bug a few days ago around log messages, so once I fix this it should resolve your issue in the futire

misakitchi commented 9 years ago

I run the query in my JMM database: select count(*) from LogMessage

Result: 561573 Yes i think the bug is here, too much logmessage...

jmediamanager commented 9 years ago

Yup that is too many There is an automated process which deletes old records from that table every day (which is failing)

If you run the command to delete those messages it should fix your issue

misakitchi commented 9 years ago

Command is : "delete from LogMessage"?

And when i active option "Use query governor to prevent long-running queries" i don't have "last episodes" files in dashbord

misakitchi commented 9 years ago

Also, if anyone is seeing JMM Server using more than 0% CPU, I would recommend changing the following in the config file.

logger name="_" minlevel="Info" writeTo="file,console"/ to

Then check to logs to see if JMM Server is actually logging anything, when you think it should be doing nothing

=> its the same issue?

jmediamanager commented 9 years ago

yes run that delete statement and also turn off that option