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

When using Redis to sync comments, it always returns with Map must not be empty. #5

Open
House-Kitty-Mew opened this issue Mar 4, 2024 · 19 comments

Comments

@House-Kitty-Mew
Copy link

I tried running my own redis and allowing outside connections, I tried a local install but nothing was working.

@zbx1425
Copy link
Owner

zbx1425 commented Mar 4, 2024

Btw why would you want to use Redis? As it only applies to a rare use case where you have many servers ("sharing") using a same map

@House-Kitty-Mew
Copy link
Author

Yes I have created a modpack that generates the same seeded world each time but randomizes the location on first login, I wanted my friends to be able to play SP in their game but also be able to share their comments with everyone so you would see comments made by others in your game, kinda like dark souls or bloodborne messages on the floor..

@zbx1425
Copy link
Owner

zbx1425 commented Mar 4, 2024

I see, that's interesting
I'm not very familiar with Redis though, plus I haven't seen this error on my setup
More info on where and how that error came up?

@House-Kitty-Mew
Copy link
Author

I Know my redis server works because i did some testing with setting and removing entries remotely, but when i add the redis config in and then try to load a world, it just freezes forever and i have to force close and the crashlog just says redis failed because map must not be empty

@zbx1425
Copy link
Owner

zbx1425 commented Mar 4, 2024

Weird, mind sending the relavent part of the log over?
Also btw, the setup is supposed to be like, one server has syncRole set to host, while the others has syncRole set to subordinate.

@House-Kitty-Mew
Copy link
Author

Weird, mind sending the relavent part of the log over? Also btw, the setup is supposed to be like, one server has syncRole set to host, while the others has syncRole set to subordinate.

Ah with that information now that I understand how it works, I believe I was using it wrong.

I was trying to use Host but i was setting the url to a remote redis running on a RassberryPi, I am guessing it runs some kinda internal one that it maps too, but since its not the local one its not sending out the mapping dataset? maybe make it do a small test to see if using dedicated remote redis as the Host and merge its internal mapset with the servers?? I dont think I could run a game client all the time just to act as a hub for comments XD

@zbx1425
Copy link
Owner

zbx1425 commented Mar 4, 2024

Ah with that information now that I understand how it works, I believe I was using it wrong.

Shouldn't have that "map must not be empty" issue and crash in all cases though, wonder why
So yeah the sync function is made specific for TeaConMC's scenario and doesn't suit actual use cases x_x

TeaConMC has one "builders' server" and several "visitors' servers", the save file on builders' server gets preserved, while several visitors' servers are ran on a Kubernetes cluster, their save files are pulled from builders' server at startup and dumped at shutdown and thus it's totally griefproof
So the sync function is about syncing visitor's comments across all visitors' servers, and also sent to builder's server for getting written into save file and preserved

@House-Kitty-Mew
Copy link
Author

So it will only work for a dedicated server then? if so that's fine, I could just make then join a server to play, just some people dont got good connections lol

@zbx1425
Copy link
Owner

zbx1425 commented Mar 4, 2024

So it will only work for a dedicated server then?

I think you might be able to get it working with your public redis setup, but you do need a Minecraft server with "syncRole": "host" constantly running for anything to be saved, as a result of this being originally designed for a cluster of dedicated servers

@House-Kitty-Mew
Copy link
Author

I tried, this was the error
`[06:26:05] [Server thread/ERROR]: Encountered an unexpected exception
vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisConnectionException: Unable to connect to localhost/:6379
at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78) ~[worldcomment-0.1.21.20.1.i0:0/:?]
at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56) ~[worldcomment-0.1.21.20.1.i0:0/:?]
at vendor.cn.zbx1425.worldcomment.io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:350) ~[worldcomment-0.1.21.20.1.i0:0/:?]
at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisClient.connect(RedisClient.java:216) ~[worldcomment-0.1.21.20.1.i0:0/:?]
at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisClient.connect(RedisClient.java:201) ~[worldcomment-0.1.21.20.1.i0:0/:?]
at fabric.cn.zbx1425.worldcomment.data.sync.RedisSynchronizer.(RedisSynchronizer.java:28) ~[worldcomment-0.1.21.20.1.i0:0/:?]
at fabric.cn.zbx1425.worldcomment.Main.lambda$init$0(Main.java:48) ~[worldcomment-0.1.21.20.1.i0:0/:?]
at org.quiltmc.qsl.lifecycle.api.event.ServerLifecycleEvents.lambda$static$0(ServerLifecycleEvents.java:50) ~[quilt-lifecycle-events-6.1.21.20.1.i0:0/:?]
at net.minecraft.server.MinecraftServer.handler$eaa000$quilt_lifecycle_events$serverStarting(MinecraftServer.java:12332) ~[minecraft-1.20.1.i0:0/:?]
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:646) ~[minecraft-1.20.1.i0:0/:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[minecraft-1.20.1.i0:0/:?]
at java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: getsockopt: localhost/127.0.0.1:6379
Caused by: java.net.ConnectException: Connection refused: getsockopt
at sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]
at sun.nio.ch.Net.pollConnectNow(Net.java:682) ~[?:?]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:973) ~[?:?]
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337) ~[minecraft-1.20.1.i0:0/:?]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) ~[minecraft-1.20.1.i0:0/:?]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776) ~[minecraft-1.20.1.i0:0/:?]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[minecraft-1.20.1.i0:0/:?]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[minecraft-1.20.1.i0:0/:?]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[minecraft-1.20.1.i0:0/:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[minecraft-1.20.1.i0:0/:?]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[minecraft-1.20.1.i0:0/:?]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[minecraft-1.20.1.i0:0/:?]
... 1 more
[06:26:05] [Server thread/WARN]: Configuration conflict: there is more than one oshi.architecture.properties file on the classpath: [quilt.zfs://minecraft-1.20.1.i0:0/oshi.architecture.properties, jar:file:/C:/servers/Minecraft/PureHorror/libraries/com/github/oshi/oshi-core/6.2.2/oshi-core-6.2.2.jar!/oshi.architecture.properties]
[06:26:05] [Server thread/INFO]: Mixing common.MixinServerStatus from #nochatreports:mixins/common/nochatreports.mixins.json into net.minecraft.class_2926
[06:26:05] [Server thread/ERROR]: This crash report has been saved to: C:\servers\Minecraft\PureHorror.\crash-reports\crash-2024-03-04_06.26.05-server.txt
[06:26:05] [Server thread/INFO]: Stored scheduled creeper explosion event(s) to .\PureHorrorMap.\scheduled-explosions.json
[06:26:05] [Server thread/INFO]: Stopping server
[06:26:05] [Server thread/INFO]: Saving worlds
[06:26:05] [Server thread/ERROR]: Exception stopping the server
java.lang.NullPointerException: Cannot invoke "net.minecraft.class_3218.method_8621()" because "$$5" is null
at net.minecraft.server.MinecraftServer.method_3723(MinecraftServer.java:541) ~[minecraft-1.20.1.i0:0/:?]
at net.minecraft.server.MinecraftServer.method_3782(MinecraftServer.java:602) ~[minecraft-1.20.1.i0:0/:?]
at net.minecraft.class_3176.method_3782(class_3176.java:537) ~[minecraft-1.20.1.i0:0/:?]
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:703) ~[minecraft-1.20.1.i0:0/:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[minecraft-1.20.1.i0:0/:?]
at java.lang.Thread.run(Thread.java:1583) ~[?:?]

C:\servers\Minecraft\PureHorror>pause
Press any key to continue . . .`

@zbx1425
Copy link
Owner

zbx1425 commented Mar 4, 2024

Mmm it says it can't connect to localhost:6379
Doesn't seem to be an issue on my side

@House-Kitty-Mew
Copy link
Author

I installed it on server and set config, I am not sure what else I need to do for it?

@zbx1425
Copy link
Owner

zbx1425 commented Mar 4, 2024

If you are running redis on a remote server, then you expose it to internet and fill in the ip address or domain, the same way as how you'll let players join a dedicated Minecraft server?

@House-Kitty-Mew
Copy link
Author

No not exposed, only lan right now then iall work on redis auth later, but it crashes if i use localhost or the remote redis

vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.1.114/<unresolved>:6379
        at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78) ~[worldcomment-0.1.21.20.1.i0:0/:?]
        at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56) ~[worldcomment-0.1.21.20.1.i0:0/:?]
        at vendor.cn.zbx1425.worldcomment.io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:350) ~[worldcomment-0.1.21.20.1.i0:0/:?]
        at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisClient.connect(RedisClient.java:216) ~[worldcomment-0.1.21.20.1.i0:0/:?]
        at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisClient.connect(RedisClient.java:201) ~[worldcomment-0.1.21.20.1.i0:0/:?]
        at fabric.cn.zbx1425.worldcomment.data.sync.RedisSynchronizer.<init>(RedisSynchronizer.java:28) ~[worldcomment-0.1.21.20.1.i0:0/:?]
        at fabric.cn.zbx1425.worldcomment.Main.lambda$init$0(Main.java:48) ~[worldcomment-0.1.21.20.1.i0:0/:?]
        at org.quiltmc.qsl.lifecycle.api.event.ServerLifecycleEvents.lambda$static$0(ServerLifecycleEvents.java:50) ~[quilt-lifecycle-events-6.1.21.20.1.i0:0/:?]
        at net.minecraft.server.MinecraftServer.handler$eaa000$quilt_lifecycle_events$serverStarting(MinecraftServer.java:12332) ~[minecraft-1.20.1.i0:0/:?]
        at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:646) ~[minecraft-1.20.1.i0:0/:?]
        at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[minecraft-1.20.1.i0:0/:?]
        at java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: io.netty.channel.ConnectTimeoutException: connection timed out: /192.168.1.114:6379
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:261) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:153) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[minecraft-1.20.1.i0:0/:?]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[minecraft-1.20.1.i0:0/:?]

@House-Kitty-Mew
Copy link
Author

To note, the client works fine on the same machine.

@House-Kitty-Mew
Copy link
Author

AH heres the error I get when setting the remote redis on the server config when it tries to boot:

Encountered an unexpected exception java.lang.IllegalArgumentException: Map must not be empty at vendor.cn.zbx1425.worldcomment.io.lettuce.core.internal.LettuceAssert.isTrue(LettuceAssert.java:208) ~[worldcomment-0.1.21.20.1.i0:0/:?] at vendor.cn.zbx1425.worldcomment.io.lettuce.core.RedisCommandBuilder.hset(RedisCommandBuilder.java:1511) ~[worldcomment-0.1.21.20.1.i0:0/:?] at vendor.cn.zbx1425.worldcomment.io.lettuce.core.AbstractRedisAsyncCommands.hset(AbstractRedisAsyncCommands.java:1125) ~[worldcomment-0.1.21.20.1.i0:0/:?] at fabric.cn.zbx1425.worldcomment.data.sync.RedisSynchronizer.kvWriteAll(RedisSynchronizer.java:45) ~[worldcomment-0.1.21.20.1.i0:0/:?] at fabric.cn.zbx1425.worldcomment.data.ServerWorldData.load(ServerWorldData.java:42) ~[worldcomment-0.1.21.20.1.i0:0/:?] at fabric.cn.zbx1425.worldcomment.Main.lambda$init$0(Main.java:50) ~[worldcomment-0.1.21.20.1.i0:0/:?] at org.quiltmc.qsl.lifecycle.api.event.ServerLifecycleEvents.lambda$static$0(ServerLifecycleEvents.java:50) ~[quilt-lifecycle-events-6.1.21.20.1.i0:0/:?] at net.minecraft.server.MinecraftServer.handler$eaa000$quilt_lifecycle_events$serverStarting(MinecraftServer.java:12332) ~[minecraft-1.20.1.i0:0/:?] at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:646) ~[minecraft-1.20.1.i0:0/:?] at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[minecraft-1.20.1.i0:0/:?] at java.lang.Thread.run(Thread.java:1583) ~[?:?] [06:46:34] [Server thread/WARN]: Configuration conflict: there is more than one oshi.architecture.properties file on the classpath: [quilt.zfs://minecraft-1.20.1.i0:0/oshi.architecture.properties, jar:file:/C:/servers/Minecraft/PureHorror/libraries/com/github/oshi/oshi-core/6.2.2/oshi-core-6.2.2.jar!/oshi.architecture.properties] [06:46:34] [Server thread/INFO]: Mixing common.MixinServerStatus from #nochatreports:mixins/common/nochatreports.mixins.json into net.minecraft.class_2926 [06:46:34] [Server thread/ERROR]: This crash report has been saved to: C:\servers\Minecraft\PureHorror\.\crash-reports\crash-2024-03-04_06.46.34-server.txt [06:46:34] [Server thread/INFO]: Stored scheduled creeper explosion event(s) to .\PureHorrorMap\.\scheduled-explosions.json [06:46:34] [Server thread/INFO]: Stopping server [06:46:34] [Server thread/INFO]: Saving worlds [06:46:34] [Server thread/ERROR]: Exception stopping the server java.lang.NullPointerException: Cannot invoke "net.minecraft.class_3218.method_8621()" because "$$5" is null at net.minecraft.server.MinecraftServer.method_3723(MinecraftServer.java:541) ~[minecraft-1.20.1.i0:0/:?] at net.minecraft.server.MinecraftServer.method_3782(MinecraftServer.java:602) ~[minecraft-1.20.1.i0:0/:?] at net.minecraft.class_3176.method_3782(class_3176.java:537) ~[minecraft-1.20.1.i0:0/:?] at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:703) ~[minecraft-1.20.1.i0:0/:?] at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:265) ~[minecraft-1.20.1.i0:0/:?] at java.lang.Thread.run(Thread.java:1583) ~[?:?]

@zbx1425
Copy link
Owner

zbx1425 commented Mar 4, 2024

Ah I see where the issue is
I used lettuce's hset function to batch upload existing comments in host server to redis
For some reason, the lettuce library decides that when I pass an empty HashMap to it (when there are not existing comments), it should throw an exception instead of like inserting nothing
As a workaround try removing redis config, writing a comment somewhere, save, then put redis config back and restart

@House-Kitty-Mew
Copy link
Author

Ah I see where the issue is I used lettuce's hset function to batch upload existing comments in host server to redis For some reason, the lettuce library decides that when I pass an empty HashMap to it (when there are not existing comments), it should throw an exception instead of like inserting nothing As a workaround try removing redis config, writing a comment somewhere, save, then put redis config back and restart

This kinda works? it worked at first launch after setting comment but upon reload of the world now, poof

@House-Kitty-Mew
Copy link
Author

Would a simple dummy insert on every load pretty much fix this?
I already went mad this week trying to fix it and if I go into your source code I might jump a bridge, haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants