全部產品
Search
文件中心

Function Compute:使用Jedis串連池模式報錯Could not get a resource from the pool如何解決?

更新時間:Aug 20, 2025

本文介紹報錯Could not get a resource from the pool的原因和解決方案。

問題現象

使用Java運行環境Jedis串連池模式遇到報錯Could not get a resource from the pool

可能原因

  • Tair (Redis OSS-compatible)白名單配置錯誤。

  • 其他錯誤。

解決方案

首先,在Cause Exception日誌中找到以Caused by:開頭的日誌,然後根據日誌進行分析。樣本日誌如下:

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
  ....
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR client ip is not in whitelist xxx:xxx
說明

使用getStackTrace()無法列印出Caused by:日誌,需要直接輸出exception或者使用getCause()方法列印。

ERR client ip is not in whitelist xxx:xxx

Tair (Redis OSS-compatible)白名單配置錯誤,需重新設定白名單。具體操作,請參見設定資料庫訪問IP地址白名單

重要

如果該報錯是偶然現象,請檢查是否使用了安全性群組的方式訪問資料庫。安全性群組方式會導致函數串連不穩定,影響業務正常運行,建議改為IP地址白名單方式。

其他報錯

如果遇到其他報錯,例如Timeout waiting for idle objectPool exhausted,請參見Tair (Redis OSS-compatible)的以下文檔進行排查。