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

Thread crashing instead of returning errors. #85

Closed
Xd-pro opened this issue Aug 14, 2022 · 10 comments · Fixed by #106
Closed

Thread crashing instead of returning errors. #85

Xd-pro opened this issue Aug 14, 2022 · 10 comments · Fixed by #106
Labels

Comments

@Xd-pro
Copy link

Xd-pro commented Aug 14, 2022

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

@Endermanbugzjfc
Copy link
Contributor

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?

@Xd-pro
Copy link
Author

Xd-pro commented Aug 14, 2022

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
Copy link
Author

Xd-pro commented Aug 14, 2022

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

@SOF3
Copy link
Member

SOF3 commented Aug 14, 2022

related: #71

@SOF3 SOF3 added the bug label Aug 14, 2022
@ZoumiSurGithub
Copy link

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

@ZoumiSurGithub
Copy link

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.

@SOF3
Copy link
Member

SOF3 commented Jul 27, 2023

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

@ZoumiSurGithub
Copy link

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?

@SOF3
Copy link
Member

SOF3 commented Jul 28, 2023

if anyone sends a pull request to fix it

@cherrychip8293
Copy link

if anyone sends a pull request to fix it

When will the problem be solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants