libasynql icon indicating copy to clipboard operation
libasynql copied to clipboard

Thread crashing instead of returning errors.

Open Xd-pro opened this issue 2 years ago • 4 comments

Describe the bug

Stack trace:
#0 [internal function]: pocketmine\errorhandler\ErrorToExceptionHandler::handle(2, 'SQLite3Stmt::ex...', 'D:\\projects\\poc...', 89)
#1 D:\projects\pocketmine-dev-env-new\virions\libasynql\src\poggit\libasynql\sqlite3\Sqlite3Thread.php(89): SQLite3Stmt->execute()
#2 D:\projects\pocketmine-dev-env-new\virions\libasynql\src\poggit\libasynql\base\SqlSlaveThread.php(88): poggit\libasynql\sqlite3\Sqlite3Thread->executeQuery(Object(SQLite3), 2, 'INSERT\nINTO pla...', Array)
#3 phar://D:/projects/pocketmine-dev-env-new/PocketMine-MP.phar/src/thread/CommonThreadPartsTrait.php(93): poggit\libasynql\base\SqlSlaveThread->onRun()
#4 [internal function]: pocketmine\thread\Thread->run()
#5 {main}
  thrown in D:\projects\pocketmine-dev-env-new\virions\libasynql\src\poggit\libasynql\sqlite3\Sqlite3Thread.php on line 89

Sample code Query:

INSERT
INTO players (xuid, ip) 
VALUES (:xuid, :ip)

Table:

CREATE TABLE IF NOT EXISTS players (
	xuid VARCHAR(255) NOT NULL PRIMARY KEY ON CONFLICT ABORT,
	ip VARCHAR(255) NOT NULL,
	permBanned BOOLEAN NOT NULL DEFAULT FALSE,
	unbanAt INT NOT NULL DEFAULT 0,
	warns INT NOT NULL DEFAULT 0
)

Expected behavior Errors would be returned in the onError function.

Environment OS: Windows PocketMine version: 4.7.0 / 1.19.20

Xd-pro avatar Aug 14 '22 12:08 Xd-pro

Describe the bug

Stack trace:
#0 [internal function]: pocketmine\errorhandler\ErrorToExceptionHandler::handle(2, 'SQLite3Stmt::ex...', 'D:\\projects\\poc...', 89)
#1 D:\projects\pocketmine-dev-env-new\virions\libasynql\src\poggit\libasynql\sqlite3\Sqlite3Thread.php(89): SQLite3Stmt->execute()
#2 D:\projects\pocketmine-dev-env-new\virions\libasynql\src\poggit\libasynql\base\SqlSlaveThread.php(88): poggit\libasynql\sqlite3\Sqlite3Thread->executeQuery(Object(SQLite3), 2, 'INSERT\nINTO pla...', Array)
#3 phar://D:/projects/pocketmine-dev-env-new/PocketMine-MP.phar/src/thread/CommonThreadPartsTrait.php(93): poggit\libasynql\base\SqlSlaveThread->onRun()
#4 [internal function]: pocketmine\thread\Thread->run()
#5 {main}
  thrown in D:\projects\pocketmine-dev-env-new\virions\libasynql\src\poggit\libasynql\sqlite3\Sqlite3Thread.php on line 89

Sample code Query:

INSERT
INTO players (xuid, ip) 
VALUES (:xuid, :ip)

Table:

CREATE TABLE IF NOT EXISTS players (
	xuid VARCHAR(255) NOT NULL PRIMARY KEY ON CONFLICT ABORT,
	ip VARCHAR(255) NOT NULL,
	permBanned BOOLEAN NOT NULL DEFAULT FALSE,
	unbanAt INT NOT NULL DEFAULT 0,
	warns INT NOT NULL DEFAULT 0
)

Expected behavior Errors would be returned in the onError function.

Environment OS: Windows PocketMine version: 4.7.0 / 1.19.20

What is the error message above the stack trace?

Endermanbugzjfc avatar Aug 14 '22 14:08 Endermanbugzjfc

Fatal error: Uncaught ErrorException: SQLite3Stmt::execute(): Unable to execute statement: UNIQUE constraint failed: players.xuid in D:\projects\pocketmine-dev-env-new\virions\libasynql\src\poggit\libasynql\sqlite3\Sqlite3Thread.php:89

Xd-pro avatar Aug 14 '22 15:08 Xd-pro

Wrapping the code that runs the query in a try/catch does nothing.

Xd-pro avatar Aug 14 '22 15:08 Xd-pro

related: #71

SOF3 avatar Aug 14 '22 15:08 SOF3

Hello, when do you plan to release an update (containing the bug fix)?

ZoumiSurGithub avatar Jul 25 '23 22:07 ZoumiSurGithub

I've done some research and it seems that it's the synchronised used to wait for responses during the waitAll that's blocking everything, when there's a crash, and we close the server with a waitAll to wait for all the query responses, the synchronised loops around without returning anything.

ZoumiSurGithub avatar Jul 26 '23 12:07 ZoumiSurGithub

It is simply because the thread does not try to catch errors, thus never sending SqlErrorResult properly

SOF3 avatar Jul 27 '23 04:07 SOF3

It is simply because the thread does not try to catch errors, thus never sending SqlErrorResult properly

When do you plan to solve this problem?

ZoumiSurGithub avatar Jul 27 '23 14:07 ZoumiSurGithub

if anyone sends a pull request to fix it

SOF3 avatar Jul 28 '23 02:07 SOF3

if anyone sends a pull request to fix it

When will the problem be solved?

cherrychip8293 avatar Jul 28 '23 17:07 cherrychip8293