ForkJoinPool.commonPool 的线程在调用 OpenFGA 的 CompletableFuture 方法时无限期地创建新的,而不是重用/关闭

问题描述 投票:0回答:1

我的应用程序正在打开数千个新的 ForkJoinPool 池和线程,它们从未关闭,而是保持在

WAIT
状态,直到程序最终抛出 OOM 错误(但仍然不会崩溃):

jakarta.servlet.ServletException: Handler dispatch failed: java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
// ...stacktrace
[95433.690s][warning][os,thread] Failed to start thread "Unknown thread" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
[95433.691s][warning][os,thread] Failed to start the native thread for java.lang.Thread "pool-1917-thread-1"
Caused by: java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

我的程序中唯一使用 ForkJoinPool 的部分来自 openfga 库,例如:

// my code that calls the library
var response = fgaClient.listRelations(body, options).get();

// listRelations() in the library
public CompletableFuture<ClientListRelationsResponse> listRelations(ClientListRelationsRequest request, ClientListRelationsOptions listRelationsOptions) throws FgaInvalidParameterException {
  // implementation...

  return this.batchCheck(batchCheckRequests, options.asClientBatchCheckOptions())
                .thenCompose(responses -> call(() -> ClientListRelationsResponse.fromBatchCheckResponses(responses)));
}

有人可以告诉我发生了什么事吗?我该如何解决这个问题?

spring multithreading open-fga
1个回答
0
投票

感谢您提出这个问题。在这种情况下,这是底层 OpenFGA SDK 中的错误。

我们正在跟踪它here,并且有一个 PR 并修复了它,应该很快就会合并。

由于这是库中的错误,我建议在此处关闭问题并按照链接的问题进行更新。

© www.soinside.com 2019 - 2024. All rights reserved.