Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync initial connection can cause *very* long waits #60

Open
JaxkDev opened this issue Apr 23, 2021 · 3 comments
Open

Sync initial connection can cause *very* long waits #60

JaxkDev opened this issue Apr 23, 2021 · 3 comments
Labels

Comments

@JaxkDev
Copy link
Member

JaxkDev commented Apr 23, 2021

Describe the bug
During initial construction of the libasynql if you have a internet connection issue or DB issue you can expect waits of up to 3 minutes PER plugin that uses libasynql.

Sample code

$this->db = libasynql::create($plugin, @yaml_parse_file($plugin->getDataFolder()."mysql.yml"), [
	"sqlite" => "sqlite.sql",
	"mysql" => "mysql.sql"
]);

Expected behavior
Smaller timeout or connection made async (not sure how its done backend)

Environment
OS: Windows 10
PocketMine version: 3.19.0
PHP: 8.0.3

Log

[17:22:26] [Server thread/INFO]: Loading FusionCore v1.0.0
[17:22:26] [Asynchronous Worker #0 thread/DEBUG]: Set memory limit to 256 MB
status
[17:24:49] [Server thread/CRITICAL]: FusionCraft\Core\vendor9a5a9370\poggit\libasynql\SqlError: "SQL CONNECT error: MySQL server has gone away" (EXCEPTION) in "plugins/FusionCore.phar/src/FusionCraft/Core/vendor9a5a9370/p
oggit/libasynql/libasynql" at line 141
[17:24:49] [Server thread/CRITICAL]: #0 plugins/FusionCore.phar/src/FusionCraft/Core/SharedDatabase(29): FusionCraft\Core\vendor9a5a9370\poggit\libasynql\libasynql::create(string[31] object(FusionCraft\Core\Plugin), array
[4], array[2])
[17:24:49] [Server thread/CRITICAL]: #1 plugins/FusionCore.phar/src/FusionCraft/Core/Plugin(24): FusionCraft\Core\SharedDatabase->__construct(string[31] object(FusionCraft\Core\Plugin))
[17:24:49] [Server thread/CRITICAL]: #2 pmsrc/src/pocketmine/plugin/PluginManager(182): FusionCraft\Core\Plugin->onLoad()
[17:24:49] [Server thread/CRITICAL]: #3 pmsrc/src/pocketmine/plugin/PluginManager(346): pocketmine\plugin\PluginManager->loadPlugin(string[81] C:\Users\Jack\Documents\PocketMine\FusionCraft-PMMP3-PHP8\plugins\FusionCore.p
ha, array[2])
[17:24:49] [Server thread/CRITICAL]: #4 pmsrc/src/pocketmine/Server(1529): pocketmine\plugin\PluginManager->loadPlugins(string[66] C:\Users\Jack\Documents\PocketMine\FusionCraft-PMMP3-PHP8\plugins\)
[17:24:49] [Server thread/CRITICAL]: #5 pmsrc/src/pocketmine/PocketMine(291): pocketmine\Server->__construct(string[23] object(BaseClassLoader), string[35] object(pocketmine\utils\MainLogger), string[58] C:\Users\Jack\Doc
uments\PocketMine\FusionCraft-PMMP3-PHP8\, string[66] C:\Users\Jack\Documents\PocketMine\FusionCraft-PMMP3-PHP8\plugins\)
[17:24:49] [Server thread/CRITICAL]: #6 pmsrc/src/pocketmine/PocketMine(321): pocketmine\server()
[17:24:49] [Server thread/CRITICAL]: #7 pmsrc(11): require(string[113] phar://C:/Users/Jack/Documents/PocketMine/FusionCraft-PMMP3-PHP8/PocketMine-MP.p)
[17:24:49] [Server thread/CRITICAL]: Could not load plugin 'FusionCore'

Take note of timestamps, if several plugins were to have libasynql and they all failed like above during initial connection that could be an extremely long wait before the user can interact with the server (stop command etc)

@SOF3
Copy link
Member

SOF3 commented Apr 24, 2021

Seems to be this loop

while(!$pool->connCreated()){
usleep(1000);
}

Could make this async indeed.

@Endermanbugzjfc
Copy link
Contributor

Endermanbugzjfc commented Apr 24, 2021

Yes, I used to have a plugin that attempt to reconnect the database every 5 minutes if the connection failed has on enable. And it really did make people think I'm running queries on main thread oof.

@JaxkDev
Copy link
Member Author

JaxkDev commented Apr 27, 2021

Not sure if this is directly related but I'm seeing very long waits on close() as well.

[17:53:10] [Server thread/INFO]: Disabling FusionCore v1.0.0
[17:53:13] [RakLibServer thread/DEBUG]: Closed session for 172.20.10.1 52534
[17:53:13] [RakLibServer thread/DEBUG]: Ignored connected packet from 172.20.10.1 52534 due to no session opened (0xc0)
[17:54:24] [Server thread/INFO]: JaxkDev left the game
[17:54:25] [Server thread/INFO]: JaxkDev[/172.20.10.1:52534] logged out due to Server closed
[17:54:25] [Server thread/DEBUG]: Unloading all worlds
[17:54:25] [Server thread/INFO]: Unloading world "world"
[17:54:25] [Server thread/DEBUG]: Removing event handlers

1m 25s to close, the only thing called on disable is this: $this->db->close(); where $this->db is the data connector from the return of libasynql::create()

@SOF3 SOF3 added bug and removed enhancement labels Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants