azerothcore / azerothcore-wotlk

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

[BUG] Wrong Async queries (especially for pets) and room for improvements #5178

Open Yehonal opened 3 years ago

Yehonal commented 3 years ago

I've found a technical issue related to the way certain functions are using the AsyncQuery method.

Intro: What is AsyncQuery in AC

Currently we have 3 ways to execute a query:

  1. Enqueue without result (Execute) pro: it doesn't lock the db so doesn't cause performance issues cons: doesn't return anything and you cannot write sequential code

  2. Execute with sync result (Query) pro: returns the result of the query and you can write sequential code cons: it locks the db so can cause performance issues

  3. Enqueue with async result (AsyncQuery) pro: returns the result of the query and you can write async code cons: it's a bit more complex to use (not 1 line of code)

Issue N.1: Pets etc.

I've noticed that certain methods are using the AsyncQuery as they were synchronous instead.

This is the list of wrongly used async queries:

image

I'm not 99% sure but I think that every time you run those queries in the best scenario it's a gamble against your I/O speed, in the worst scenario instead that logic is completely broken

Issue N.2: Complexity (optional)

Would be great to find a way to allow devs to easily use the AsyncQuery approach since, in my opinion, it should be vastly used especially for scripts.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/97693776-bug-wrong-async-queries-especially-for-pets-and-room-for-improvements?utm_campaign=plugin&utm_content=tracker%2F40032087&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F40032087&utm_medium=issues&utm_source=github).
Yehonal commented 3 years ago

bump

Winfidonarleyan commented 3 years ago

4669

Yehonal commented 3 years ago

4669

not sure if that is related to this problem

Yehonal commented 3 years ago

Any updates here? @Winfidonarleyan were you working on Async recently?

FrancescoBorzi commented 3 years ago

not sure if @UltraNix did something about this recently

UltraNix commented 3 years ago

Nope.

Winfidonarleyan commented 3 years ago

Any updates here? @Winfidonarleyan were you working on Async recently?

No