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

Flat file storage race condition #4398

Closed
1 task done
SaFiKiK opened this issue Oct 31, 2021 · 0 comments
Closed
1 task done

Flat file storage race condition #4398

SaFiKiK opened this issue Oct 31, 2021 · 0 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. variables Related to variables and/or storing them.

Comments

@SaFiKiK
Copy link

SaFiKiK commented Oct 31, 2021

Skript/Server Version

[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript] Skript's documentation can be found here: https://skriptlang.github.io/Skript
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript] Server Version: git-Paper-338 (MC: 1.17.1)
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript] Skript Version: 2.6
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript] Installed Skript Addons:
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript]  - SkUniversal v2.12.5
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript]  - Skellett v1.9.11 (https://forums.skunity.com/resources/skellett.24/)
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript]  - skript-gui v1.3-alpha3 (https://github.com/APickledWalrus/skript-gui)
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript]  - SkQuery v4.1.5
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript]  - SkBee v1.11.4 (https://github.com/ShaneBeee/SkBee)
[Sun, 31. Oct 2021 15:18:40 GMT INFO] [Skript]  - skript-holo v1.0.2 (https://github.com/Blueyescat/skript-holo)

Bug Description

Creating multiple Flat File databases leads to race condition when they try to save variables. When there are thousands (or even millions) of variables to save, for different databases, multiple threads try to access the same file called variables.csv.temp. This leads to random data being saved into different databases. While the server is online, all Flat Storage Files will have random data from the other databases. After the server shutdown, all data in files become normal. This also produces errors in console (pasted further in report).

Expected Behavior

Each Flat File Storage creates its own temp variables file and uses this file to write variables to the database.

Probably, just change "variables.csv.temp" to name + ".csv.temp"?

Steps to Reproduce

  1. Create multiple Flat File Databases in Skript config
  2. Start the server, run any function which will save a lot of variables to different databases
  3. Wait for saveTask to run.

Errors or Screenshots

[12:14:06 UTC ERROR] [Skript] Unable to make a final save of the database 'default' (no variables are lost): plugins/Skript/variables.csv.temp -> /home/minecraft/server/./plugins/Skript/variables.csv
[12:14:06 UTC ERROR] [Skript] Unable to make a final save of the database 'blockdata' (no variables are lost): plugins/Skript/variables.csv.temp -> /home/minecraft/server/./plugins/Skript/Data/BlockData.csv
[12:14:06 UTC ERROR] [Skript] Unable to make a final save of the database 'ranks' (no variables are lost): plugins/Skript/variables.csv.temp -> /home/minecraft/server/./plugins/Skript/Data/Ranks.csv
[12:14:06 UTC ERROR] [Skript] Unable to make a final save of the database 'itemdata' (no variables are lost): plugins/Skript/variables.csv.temp -> /home/minecraft/server/./plugins/Skript/Data/ItemData.csv

Other

No response

Agreement

  • I have read the guidelines above and confirm I am following them with this report.
@TPGamesNL TPGamesNL added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. variables Related to variables and/or storing them. labels Oct 31, 2021
@TPGamesNL TPGamesNL added PR available Issues which have a yet-to-be merged PR resolving it completed The issue has been fully resolved and the change will be in the next Skript update. and removed PR available Issues which have a yet-to-be merged PR resolving it labels Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. variables Related to variables and/or storing them.
Projects
None yet
Development

No branches or pull requests

3 participants