Skip to content

[Bug] Increasing Thread Count Leading to Server Crash #54

@FZnachor

Description

@FZnachor

Describe the bug

Hello, I've observed a continually increasing count of threads during the server's uptime (PaperMC 1.21.11).

Initially, when I start the server and allow BlueMap to load, it uses approximately 130-150 threads. However, after running the server for several hours, the thread count rises drastically to 460 threads. This behavior began occurring after switching from the SQL backend to the S3 backend.

Eventually, when there are too many threads (after 2 days of uptime on a 12k x 12k map), the server crashes with the following log message:

java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
	at java.base/java.lang.Thread.start0(Native Method)
	at java.base/java.lang.Thread.start(Thread.java:1553)
	at java.base/java.lang.System$2.start(System.java:2577)
	at java.base/jdk.internal.vm.SharedThreadContainer.start(SharedThreadContainer.java:152)
	at java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:953)
	at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1375)
	at io.papermc.paper.connection.PaperConfigurationTask.start(PaperConfigurationTask.java:35)
	at net.minecraft.server.network.ServerConfigurationPacketListenerImpl.startNextTask(ServerConfigurationPacketListenerImpl.java:243)
	at net.minecraft.server.network.ServerConfigurationPacketListenerImpl.finishCurrentTask(ServerConfigurationPacketListenerImpl.java:258)
	at net.minecraft.server.network.ServerConfigurationPacketListenerImpl.handleSelectKnownPacks(ServerConfigurationPacketListenerImpl.java:179)
	at net.minecraft.network.protocol.configuration.ServerboundSelectKnownPacks.handle(ServerboundSelectKnownPacks.java:23)
	at net.minecraft.network.protocol.configuration.ServerboundSelectKnownPacks.handle(ServerboundSelectKnownPacks.java:11)
	at net.minecraft.network.PacketProcessor$ListenerAndPacket.handle(PacketProcessor.java:99)
	at net.minecraft.network.PacketProcessor.executeSinglePacket(PacketProcessor.java:33)
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1504)
	at net.minecraft.server.MinecraftServer.recordTaskExecutionTimeWhileWaiting(MinecraftServer.java:1230)
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1346)
	at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:388)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Steps to reproduce the bug

  1. Enable the S3 backend and ensure the map generation is in progress.
  2. Record the Java thread count at startup using the command: ps -eLF | grep java | wc -l
  3. Allow the server to run for several hours.
  4. After the duration, check the Java thread count again with the command: ps -eLF | grep java | wc -l
  5. Note that the thread count has increased significantly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions