-
Notifications
You must be signed in to change notification settings - Fork 3
Description
After a certain period of time (normally around 12 to 24 hours), the translations will suddenly stop working. This is caused by a Java standard library problem, and needs to be worked around.
For now, if translations suddenly pause, just run /unitytranslate debugreload. You may need to run this multiple times.
Technical explanation
Apparently, Java just leaves some HTTP connections open even if they have failed, and as a result they just don't end up closing/releasing, which just straight up causes a deadlock if there are too many HTTP connections.
The reason why /unitytranslate debugreload fixes this is because I recently moved translation API calls to use a ForkJoinPool, and the reload would reset the ForkJoinPool and forcibly close all HTTP connections in that thread pool (which also explains the log spam if you have -Dunitytranslate.printHttpErrors=true enabled).
Further explanation towards this problem can be found in this Medium post.
Below is some information I stored previously just to explain the problem, if you want to read more about what I considered, here you go.
Discarded Solutions
Using Ktor for HTTP requests
Due to an actual problem with Kotlin on Forge 1.20.1 and 1.20.4 (thedarkcolour/KotlinForForge#86), Ktor is completely out of the question from being used as a solution. I was forced to throw Ktor out the window (e842f60) just to be able to support Forge, and Connector couldn't seem to handle Ktor properly either.
Using OkHttp for HTTP requests
Just like the prior problem with Ktor, OkHttp is not a viable solution due to its Kotlin usage.
Rewriting the HTTP handlers to use the logic provided in the Medium post
This ends up becoming way too much effort for what it's worth, especially because this is an incredibly slow problem to fix (requires multiple concurrent translations, appears to only occur after a period of 12-24 hours or so, etc.), so this is not a viable solution.
Possible Solutions
Rewrite HTTP handlers to use Apache's HTTP Clients API
This is what 1ea2dd8 does, but we need further testing to see if this actually helps.