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

MongoSK crashing server repeatedly #96

Open
JIBSIL opened this issue Sep 11, 2024 · 1 comment
Open

MongoSK crashing server repeatedly #96

JIBSIL opened this issue Sep 11, 2024 · 1 comment
Labels
bug v3 Planned for the v3 version

Comments

@JIBSIL
Copy link

JIBSIL commented Sep 11, 2024

🔖 Versions

[22:23:26 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[22:23:26 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[22:23:26 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[22:23:26 INFO]: [Skript] Server Version: 1.20.6-2232-f1c87e4 (MC: 1.20.6)
[22:23:26 INFO]: [Skript] Skript Version: 2.8.6 (skriptlang-github)
[22:23:26 INFO]: [Skript] Installed Skript Addons: 
[22:23:26 INFO]: [Skript]  - Skript-AnvilGUI v1.9
[22:23:26 INFO]: [Skript]  - skript-gui v1.3 (https://github.com/APickledWalrus/skript-gui)
[22:23:26 INFO]: [Skript]  - DiSky v4.17.2
[22:23:26 INFO]: [Skript]  - MongoSK v2.3.2 (https://github.com/Romitou/MongoSK)
[22:23:26 INFO]: [Skript]  - skript-reflect v2.4 (https://github.com/SkriptLang/skript-reflect)
[22:23:26 INFO]: [Skript]  - SkQuery v4.1.10
[22:23:26 INFO]: [Skript]  - SkBee v3.5.3 (https://github.com/ShaneBeee/SkBee)
[22:23:26 INFO]: [Skript]  - SkriptJSON v1.0.0
[22:23:26 INFO]: [Skript] Installed dependencies: 
[22:23:26 INFO]: [Skript]  - Vault v1.7.3-b131
[22:23:26 INFO]: [Skript]  - WorldGuard v7.0.10+d9424b1

✒️ Description

Hi - first of all, great project you have here! I've used MongoSK for a while and it's always been quite stable, until I started doing more operations per second on it. Specifically, we migrated many variables like tokens and fishing, into MongoDB because of its superior scalability compared to Skript's inbuilt data storage. I've been having crashes every few hours, always with the same message. It looks like it's just timing out waiting on the database, but we are running a pretty stable database on the same machine, and our network (Hetzner) very rarely has issues with stability. I've set the read and connect timeouts to 60000ms just to try to prevent crashing, with no luck. I'm out of ideas for what's happening here.

Code that we use to manipulate mongodb:

function mongo_getPlayer(p: offline player) :: object:
	set {_doc} to first mongo document with mongosk filter where field "_id" is uuid of {_p} of collection {-Database::playersCollection}
	if {_doc} is not set:
		ug_newPlayer({_p}) # this is a function from our gencore, don't need to worry about this!
	return {_doc}

function mongo_getMultiplier(p: player) :: object:
	set {_doc} to mongo_getPlayer({_p})
	set {_item} to mongo value "stats_multiplier" of {_doc}
	if {_item} is not set:
		set mongo value "stats_multiplier" of {_doc} to 1
		update mongo document {_doc} of {-Database::playersCollection}
	return {_item}

function mongo_setMultiplier(p: player, i: number):
	set {_doc} to mongo_getPlayer({_p})
	set mongo value "stats_multiplier" of {_doc} to {_i}
	update mongo document {_doc} of {-Database::playersCollection}

⚙️ Expected behavior

Stability was expected, as mongosk has typically been very stable with my server

🔎 Steps to reproduce

Code is posted in the description section, but I think it occurs when you are writing a lot to the database at the same time.

📸 Errors or screenshots

Logfile on mclo.gs

🤔 Other

No response

@Romitou
Copy link
Owner

Romitou commented Nov 9, 2024

Hello, thank you for posting this issue. I apologise for the delay in responding.

Unfortunately, I don't have any information about your problem. The addon only acts as an interface between the Skript syntaxes and the official MongoDB driver. This problem may be caused by a temporary network problem between your MC server and your Mongo cluster, or by an interruption of some kind to the Mongo cluster service. It could also be a driver problem. Without a more thorough investigation, it will not be possible to determine the cause.

That said, it would be incorrect to say that the addon has no responsibility for this problem: a connection timeout should NOT crash the server and should be handled by the addon. This is one of the most problematic points of this version of MongoSK, which does not manage these specific cases.

There is a solution to this problem: execute Mongo operations using skript-reflect with the async section. At the same time, I'm thinking about developing a new major version to deal with all these problems (a new major version will be necessary, as the logic and syntax will have to be changed).

I am at your service if you have any questions and I hope to find the time to propose solutions directly implemented in the addon.

@Romitou Romitou added bug v3 Planned for the v3 version labels Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v3 Planned for the v3 version
Projects
None yet
Development

No branches or pull requests

2 participants