I'm using MySQL in skrypt and the server stops.

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Jxxhx

Member
Sep 29, 2024
2
0
1
23
[01:48:36 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[01:48:36 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[01:48:36 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[01:48:36 INFO]: [Skript] Server Version: git-Paper-381 (MC: 1.20.4)
[01:48:36 INFO]: [Skript] Skript Version: 2.9.2-nightly-0ece0ee (skriptlang-nightly)
[01:48:36 INFO]: [Skript] Installed Skript Addons:
[01:48:36 INFO]: [Skript] - skript-placeholders v1.5.2 (https://github.com/APickledWalrus/skript-placeholders)
[01:48:36 INFO]: [Skript] - Skellett v2.0.9 (https://forums.skunity.com/resources/skellett.24/)
[01:48:36 INFO]: [Skript] - HQGiftBoxSK v1.0.0
[01:48:36 INFO]: [Skript] - skUtilities v0.9.2 (https://tim740.github.io/)
[01:48:36 INFO]: [Skript] - skript-reflect v2.5.1 (https://github.com/SkriptLang/skript-reflect)
[01:48:36 INFO]: [Skript] - CoroutineSK v1.0.1
[01:48:36 INFO]: [Skript] - skRayFall v1.9.28 (https://sk.rayfall.net/)
[01:48:36 INFO]: [Skript] - SkQuery v4.1.10
[01:48:36 INFO]: [Skript] - SkBee v3.4.3 (https://github.com/ShaneBeee/SkBee)
[01:48:36 INFO]: [Skript] - ItemsAdder v3.6.3-beta-12 (devs.beer)
[01:48:36 INFO]: [Skript] Installed dependencies:
[01:48:36 INFO]: [Skript] - SQLibrary v7.1
[01:48:36 INFO]: [Skript] - Vault v1.7.3-b131
[01:48:36 INFO]: [Skript] - WorldGuard v7.0.9+5934e49

I added the 'SQLibrary' plug-in and set 'config.sk ' as stated in 'config.sk ' of the 'Skrypt' plug-in. A month ago, the console only printed the following error messages from time to time, which was not a big problem. But now the server pauses for about 10 seconds with another error message.

'monitor interval' cannot be increased, if it is increased, the data will not be saved when the proxy moves the channel.

This problem often happens when there are a lot of users on the server and I think if there is a lot of data storage, the server stops.

[19:34:39 INFO]: [Skript] Cannot load variables from the database fast enough (loading took 32.775s, monitor interval = 1.0s). Please increase your monitor interval or reduce usage of variables. (this warning will be repeated at most once every 10 seconds)

[19:34:05 INFO]: [Skript] database error: Deadlock found when trying to get lock; try restarting transaction

errror message
 
Here's what you can do:
Optimize Database Configuration
In your MySQL configuration file (my.cnf or my.ini):

innodb_buffer_pool_size = 1G (or higher based on your server RAM)
innodb_lock_wait_timeout = 120
innodb_deadlock_detect = ON
max_connections = 150

Skript Database Settings
Create a new file called database_settings.sk with optimized connection settings:

options:
max_connections: 10
connection_timeout: 5000
idle_timeout: 600000

Variable Usage Optimization
Use local variables ({_varname}) instead of global variables ({varname}) when possible
Clear variables when they're no longer needed
Consider using temporary storage for short-term data
Batch Processing
If you're storing large amounts of data, implement batch processing
Save data in intervals rather than continuously
Use async operations when possible
Monitor Interval Adjustment
In Skript's config.yml, adjust these settings:

database:
monitor interval: 2 seconds # Increase from 1 to 2 seconds
retry interval: 10 seconds
timeout: 5 seconds

Connection Pooling
Use HikariCP for connection pooling
Install the HikariCP plugin if available
Configure connection pool settings:

pool:
maximum-pool-size: 10
minimum-idle: 5
idle-timeout: 300000

Database Maintenance
Run these MySQL commands periodically:

OPTIMIZE TABLE skript_variables;
ANALYZE TABLE skript_variables;

Implement Variable Cleanup
Create a cleanup script that runs during low-traffic periods:

OPTIMIZE TABLE skript_variables;
ANALYZE TABLE skript_variables;

Performance Monitoring
Add monitoring to track database performance:

every 5 minutes:
set {_start} to now
# Your database operations
set {_end} to now
if difference between {_start} and {_end} > 1 second:
broadcast "&c[Warning] Database operation took %difference between {_start} and {_end}%"

Emergency Recovery
Create a backup system:

every 6 hours:
execute console command "mysqldump -u username -p database_name > backup.sql"


hope this helps!