lgang06 opened a new issue, #11113:
URL: https://github.com/apache/apisix/issues/11113

   ### Current Behavior
   
   指标过期特性存在缺陷,导致指标输出时会丢失部分已过期并重新添加的列表。
   
   
   ### Expected Behavior
   
   _No response_
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   
新版依赖的https://github.com/api7/nginx-lua-prometheus/blob/release-0.20240201/prometheus.lua指标处理库在处理已过期指标时存在缺陷,导致指标输出时会丢失部分已过期并重新添加的列表。
   可以看lookup_or_create方法的处理逻辑
   self.lookup会缓存指标的full name映射,当self.lookup_size >= self.lookup_max_size时会进行重置。
   指标首次新增,因self.lookup中没有缓存,会设置映射缓存并执行self._key_index:add(full_name, 
ERR_MSG_LRU_EVICTION, self.exptime),保存key索引关系
   因为设置了过期时间,导致一定时间后self._key_index.keys[i]的值为null。
   
   这个指标再次新增时,因为存在在self.lookup,直接返回full 
name,不会再执行self._key_index:add(),这个时候self._key_index.keys已经缺失了数据。
   
   输出指标时使用的self._key_index:list(), 遍历了self._key_index.keys列表。
   所以指标就丢失了。
   
   ### Environment
   
   - apisix version: v3.9.0


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to