Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 9, 2025

This PR fixes the recurring RRD export errors where VLAN score values exceed integer limits, causing "Number out of integers range" errors and complete data loss.

Problem

The number_to_rrd_string() function in rrd.lua was encountering VLAN score values around 1.8446744069429e+19 (close to 2^64), which exceed Lua's math.maxinteger range. When this happened, the function would:

  • Log an error message
  • Return "0" instead of the actual value
  • Cause complete data loss for affected timeseries

Solution

Instead of zeroing out overflowing values, the fix implements intelligent capping:

  • Score metrics (schemas containing ":score"): Capped to 100,000 (reasonable maximum given normal scores ~250)
  • Other metrics: Capped to math.maxinteger/2 (safe large value within integer range)
  • Logging: Changed from ERROR to WARNING since data is now preserved
  • Edge cases: Handles both positive and negative overflow correctly

Example

-- Before: Large score value → ERROR + data loss
number_to_rrd_string(1.8446744069429e+19, {name = "vlan:score"})
-- Returns: "0" (data lost)

-- After: Large score value → WARNING + capped value  
number_to_rrd_string(1.8446744069429e+19, {name = "vlan:score"})
-- Returns: "100000" (data preserved)

Benefits

  • Prevents RRD export failures and stack traces
  • Preserves high score information instead of losing it completely
  • Maintains backward compatibility for normal values
  • Provides proper debugging visibility through warning logs
  • Minimal, surgical change with comprehensive edge case handling

Fixes #9499.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Sep 9, 2025

@lucaderi 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] RRD Errors: Number out of integers range Fix RRD integer overflow by capping large values instead of zeroing them Sep 9, 2025
@Copilot Copilot AI requested a review from lucaderi September 9, 2025 08:10
Copilot finished work on behalf of lucaderi September 9, 2025 08:10
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

Successfully merging this pull request may close these issues.

RRD Errors: Number out of integers range

2 participants