azerothcore / azerothcore-wotlk

Complete Open Source and Modular solution for MMO
http://www.azerothcore.org
GNU Affero General Public License v3.0
6.63k stars 2.65k forks source link

Stuck at "Retrieving character list" for 5 minutes #877

Closed BarbzYHOOL closed 6 years ago

BarbzYHOOL commented 6 years ago

Description:

Irregularly, but often enough, when we launch AzerothCore we are stuck at "retrieving character list" just after login on our account. This concerns all the people logging in (players).

Current behaviour:

We are stuck during 2 minutes to 5 minutes (maybe more, sometimes we are stuck for more and it times out - this is not verified). Once we are able to choose our characters and enter the game, it never happens again (see Remarks below).

Expected behaviour:

This should never happen

Remarks:

Steps to reproduce the problem:

I don't know, it seems like people here have a similar issue (not sure if it's the same) https://github.com/azerothcore/azerothcore-wotlk/issues/711#issuecomment-362535892

Branch(es): 0.x / 1.x / master (Specify the branch(es) affected by this issue)

AC hash/commit:

Operating system:
On windows or on linux, same thing

PS: I started writing this issue and noticed the other issue afterwards so I let this one to refresh the problem https://github.com/azerothcore/azerothcore-wotlk/issues/711#issuecomment-362535892

AyaseCore commented 6 years ago

Yes.I'm sure there is indeed this problem. Before last year or even earlier. I build AZEROTHCORE several times.It will appear this situation. I once asked if some of my friends had this problem. They said they did not pay attention. So I always thought I was in a special situation. Others would not have this problem. Until BarbzYHOOL talks about it. I realized I wasn't the only one.

Viste commented 6 years ago

don't have this shit on SunwellCore and when use AC for tests or make pull same just login to world for seconds.

Viste commented 6 years ago

and for fix it need more info >_<

lineagedr commented 6 years ago

@Viste Actually it's the same on Sunwell Core. But less likely to happen.

AyaseCore commented 6 years ago

This issue is in the database table instance_reset. Truncation tables can avoid this problem.

src\server\game\Instances\InstanceSaveMgr.cpp void InstanceSaveManager::Update()

void InstanceSaveManager::Update()
{
    time_t now = time(NULL);
    time_t t;
    bool resetOccurred = false;

    while (!m_resetTimeQueue.empty())
    {
        t = m_resetTimeQueue.begin()->first;
        if (t >= now)
            break;

        InstResetEvent &event = m_resetTimeQueue.begin()->second;
        if (event.type)
        {
            // global reset/warning for a certain map
            time_t resetTime = GetResetTimeFor(event.mapid, event.difficulty);
            bool warn = event.type < 5;
            _ResetOrWarnAll(event.mapid, event.difficulty, warn, resetTime);
            if (warn)
            {
                // schedule the next warning/reset
                ++event.type;
                ScheduleReset(resetTime - ResetTimeDelay[event.type-1], event);
            }
            else
                resetOccurred = true;
        }
        m_resetTimeQueue.erase(m_resetTimeQueue.begin());
    }

src\server\game\Instances\InstanceSaveMgr.cpp void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, time_t resetTime)

        // calculate the next reset time
        uint32 diff = sWorld->getIntConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;

        uint32 period = uint32(((mapDiff->resetTime * sWorld->getRate(RATE_INSTANCE_RESET_TIME))/DAY) * DAY);
        if (period < DAY)
            period = DAY;

        uint32 next_reset = uint32(((resetTime + MINUTE) / DAY * DAY) + period + diff);
        SetResetTimeFor(mapid, difficulty, next_reset);
        SetExtendedResetTimeFor(mapid, difficulty, next_reset + period);
        ScheduleReset(time_t(next_reset-3600), InstResetEvent(1, mapid, difficulty));

        // update it in the DB
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
        stmt->setUInt32(0, next_reset);
        stmt->setUInt16(1, uint16(mapid));
        stmt->setUInt8(2, uint8(difficulty));
        CharacterDatabase.Execute(stmt);
  if (t >= now)
            break;

Before t >= now. It will repeat the task to the mysql thread.(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME) So it gets stuck.

It's not a big number for each update instance_reset.If the database resetTime and the real time difference are huge, it will take a long time to make t > now.

 uint32 next_reset = uint32(((resetTime + MINUTE) / DAY * DAY) + period + diff);

So we have several solutions. Is to update an SQL. Truncation table instance_reset. or clean up the different data before read table instance_reset.For example, the database data of 60 days ago. Or the database update statement is placed outside the loop. or other.

Viste commented 6 years ago

@lineagedr use sunwell for 2 YEARS AND DON'T GET IT look on your custom code

BarbzYHOOL commented 6 years ago

Viste, check out on discord "retrieving character list", it happened to several people (also on other emulators like TC). So it's confirmed, no need to discuss this

FALL1N1 commented 6 years ago

This does not happen on TrinityCore or Sunwell, either way there are shitload of issues with both sunwell/azeroth, first one for example is the 'rewritten from scratch' shit everywhere that sunwell did, some of the stuff is cool but other is plain wrong. For example i can give you a hint, start you server, explore all the continents (fly around, fight for a little) then logout and leave it like that for 7-10 days, log back again and see the magic, up to 2-3k ms delay.. Another one is that when you have high amount of players (2-3k) everything starts to lag out as it's not processed with priority, let's say you have 100bgs open as well as 100 arenas - overall world diff will be huge.. There are issues with thread handling, opcode processing and what not, too long to explain (out of my develpoment knowledge as well). Found most that issues while "implementing" the voice chat feature as i had to run trough the "bones" of the source code.

BarbzYHOOL commented 6 years ago

Sunwell ran 3k daily when it closed. There is a server running 1.6k in cuba too. So what you're saying is very unlikely, at least at first sight.

"explore all the continents (fly around, fight for a little) then logout and leave it like that for 7-10 days" this is not an accurate method to reproduce that potential GAME BREAKING issue that nobody found in all those years

Also you can open a new issue if you really care.

FALL1N1 commented 6 years ago

Thats why they said 'no easter eggs' inside. Do you really think that sunwell ran on windows? So why did we had to replace the pet loading from UInt8 to 16 in order to "load" pets properly from the database, i'm pretty sure sunwell didn't ran like this for 10+ years. I'm not saying it's bad, totally the opposite - it is good BUT they left "easter eggs" inside for sure.

For example Northcraft ran with it too and what happened? 700+ online players = 1k delay( i7-4790k/32ram or maybe higher specs) just doing bgs/arenas so please don't bother replying if you have no idea what you are dealing with.

Motorheadx commented 6 years ago

We have on the server was a chapel in 100 people on a processor 6 stack 2.00 GHz, 8 gigs operators diff did not above 11 on this nonsense say that diff jumps on such a powerful processor as i7 it has a frequency of 4-5k Ghz I do not believe it

AyaseCore commented 6 years ago

This issue is also available at sunwellcore. It's just not obvious. Or people don't realize it. Execute SQL script in characters db:

 update instance_reset set resettime = 12345;

Restart worldserver.Login the game.You'll find it takes a long time to get into the game.

BarbzYHOOL commented 6 years ago

@FALL1N1 Everything you said is very inaccurate, I have counter examples for everything you said. I know how Northcraft worked too, I know one of their developer (maybe you were too? not only on Firefly ? I don't know where you take your numbers from, my only bet is Northcraft but that's a really bad example). If you really wish to contribute to an open source project like this, we would gladly welcome you, but please, be more respectful in regards to the time we spend on it.

Let's focus on that issue instead.

Viste commented 6 years ago

@AyaseCore ok i try reproduce @FALL1N1 allmost all of writen by you is bullshit. Yes sunwellcore have some bugs( easter eggs) but they non critical and left just for fun( and teach you how to fix something by self)

AyaseCore commented 6 years ago

In my second reply above, I have already analyzed why this problem appears. @BarbzYHOOL @Viste Mysql thread is blocked.This is why the player can log in, but playercan't Get the characters list. Because the login is handled by authserver. mysql thread blocked in worldserver, so you need to wait while you query character. In fact, the issue rarely appears.(if you often open worldserver)

FALL1N1 commented 6 years ago

Barbz: Deleted insults + self advertising + attacks towards a contributor while being a proud leecher. Don't do it again, thanks.

As i said earlier i'm not trolling or harrasing anyone, just saying obvious facts as i have been working with it for over an year now and i already gave up. Anyway i will repeat my self, this issue is from the "AzerothCore" itself, it doesn't work with fresh sunwell, atleast not on 24core/ssd, you can add a check if the date is less than 7d(in seconds) from - getMStime(null) to delete the entry or skip the loop with continue so it can load the rest of the data.

p.s to the people with "1k+ online servers" better look out for opcode DoS as it's not implemented/backported.

FALL1N1 commented 6 years ago

'being a proud leecher', eh? anyway, good luck with your sunwellcore fork

Viste commented 6 years ago

@FALL1N1 good luck with your bla bla bla without proof or help :)

Motorheadx commented 6 years ago

I use Azerothcore it from the beginning and especially no problems were not thanks to all the developers and who helps with this project my respect for you! bla bla bla xDD

FrancescoBorzi commented 6 years ago

We need more code and less drama

AyaseCore commented 6 years ago

@FALL1N1 My approach is that the diff time is greater than the two reset cycles and will not execute the SQL command. It can effectively reduce the number of SQL command executions.

talamortis commented 6 years ago

@ShinDarth Nice comment, Maybe you could help find the issue :D

ghost commented 6 years ago

One way to reproduce this issue is when you first try to launch an AC server when fresh installed everything. This happens to me every single time.