Failed to save gate: Service Error
Describe the bug
I don't know what causes it, or if it's actually a problem, but this error keeps showing in my console (it used to never show).
[11:23:04 ERROR]: [MedievalFactions] Failed to save gate: Service error: Invalid version: 89 com.dansplugins.factionsystem.failure.OptimisticLockingFailureException: Invalid version: 89 at com.dansplugins.factionsystem.gate.JooqMfGateRepository.upsert(JooqMfGateRepository.kt:66) ~[medieval-factions-5.3.0-all.jar:?] at com.dansplugins.factionsystem.gate.MfGateService.save(MfGateService.kt:39) ~[medieval-factions-5.3.0-all.jar:?] at com.dansplugins.factionsystem.gate.MfGate.close$lambda-11(MfGate.kt:84) ~[medieval-factions-5.3.0-all.jar:?] at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[purpur-1.19.4.jar:git-Purpur-1985] at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[purpur-1.19.4.jar:git-Purpur-1985] at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[purpur-1.19.4.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:833) ~[?:?]
[11:33:20 ERROR]: [MedievalFactions] Failed to save gate: Service error: Invalid version: 180 com.dansplugins.factionsystem.failure.OptimisticLockingFailureException: Invalid version: 180 at com.dansplugins.factionsystem.gate.JooqMfGateRepository.upsert(JooqMfGateRepository.kt:66) ~[medieval-factions-5.3.0-all.jar:?] at com.dansplugins.factionsystem.gate.MfGateService.save(MfGateService.kt:39) ~[medieval-factions-5.3.0-all.jar:?] at com.dansplugins.factionsystem.gate.MfGate.continueOpening$lambda-9(MfGate.kt:69) ~[medieval-factions-5.3.0-all.jar:?] at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[purpur-1.19.4.jar:git-Purpur-1985] at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[purpur-1.19.4.jar:git-Purpur-1985] at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[purpur-1.19.4.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:833) ~[?:?]
To Reproduce
(Steps to reproduce the behavior) I don't know how to make it happen, but it also won't stop happening.
Expected behavior
(A clear and concise description of what you expected to happen.)
Screenshots or Logs
(If applicable, add screenshots to help explain your problem.)
Java version
- [ ] Java 8
- [ ] Java 11
- [ ] Java 16
- [x] Java 17
Plugin version
- [ ] v4.1
- [ ] v4.2
- [ ] v4.3
- [ ] v4.4
- [ ] v4.5.x
- [x] v5.3.0
Spigot/Paper version (Please Specify which server software you are using)
- [ ] 1.16.x
- [ ] 1.17.x
- [ ] 1.18.x
- [x] 1.19.4
Is this still occurring for you? @ninjakitty844
Yes, it's still happening fairly often.
I'm still not sure how to trigger the error. It doesn't happen every time I open/close a gate. One weird thing I've noticed is that the "invalid version" in the error message is always a completely random number. 73, 223, 50, 224, 956, 17, 45, etc.
One idea to address this error is to implement a retry mechanism. When an OptimisticLockingFailureException occurs, we can catch it, re-read the current state from the database, and try the update again (with a reasonable retry limit). This way, if a conflict occurs due to concurrent updates, the operation will simply retry rather than failing immediately.