Network Management
Error "Divide by zero encountered" During Database Maintenance – CPULoad_CS_Detail_hist / CPUMultiLoad_CS_Detail_hist – SolarWinds Platform
This article provides information about a database maintenance failure that occurs in SolarWinds Platform environments due to divide-by-zero errors in historical CPU tables such as CPULoad_CS_Detail_hist and CPUMultiLoad_CS_Detail_hist. The issue is caused by invalid Weight values (e.g., zero) in these tables and is commonly traced back to nodes with misconfigured polling intervals.
First published date
Last published date
Overview
During the scheduled database maintenance tasks on the SolarWinds Platform, users may encounter errors in the swdebugMaintenance.log similar to the following:
YYYY-MM-DD HH:MM:SS,SSS [1] ERROR SolarWinds.Data.DatabaseMaintenance.Reporter - [Failure] 57.31s Finalize Maintenance - CPUMultiLoad
Message:
--------------------------------------------
dbm_ExecuteMaintenance: dbm_AggregateData_part: dbm_AggregateTimeSerie_part: XACT_STATE=-1 Divide by zero error encountered.
YYYY-MM-DD HH:MM:SS,SSS [1] ERROR SolarWinds.Data.DatabaseMaintenance.Reporter - [Failure] 9.27s Finalize Maintenance - CPULoad
Message:
--------------------------------------------
dbm_ExecuteMaintenance: dbm_AggregateData_part: dbm_AggregateTimeSerie_part: XACT_STATE=-1 Divide by zero error encountered.
Upon investigation, it is found that affected entries in the CPULoad_CS_Detail_hist and CPUMultiLoad_CS_Detail_hist tables have a Weight value of 0 or NULL. The Weight column is determined during result processing and is based on the node's PollInterval. If a node has PollInterval = 0, the resulting Weight will also be 0, which causes a divide-by-zero error during aggregation operations.
This can cause the database maintenance process to fail and potentially impact reporting and performance data accuracy.
Product section
Cause
This issue may occur when one or more nodes in the NodesData table have PollInterval or RediscoveryInterval values set to 0. These values cannot be configured as 0 through the SolarWinds web console, so they may have been altered through:
- Direct custom SQL queries against the database
- Unexpected behavior from custom integrations or scripts
- Legacy data issues or a product defect (still under investigation)
When the PollInterval is 0, the Weight calculated during result storage is also 0, which leads to divide-by-zero errors during maintenance tasks.
Resolution
Important: Back up your database before making any direct SQL changes.
To resolve the issue, follow these steps:
Step 1: Fix Polling Intervals for All Affected Nodes
Update nodes that have PollInterval or RediscoveryInterval set to 0 with default values.
-- Scripts are not supported under any SolarWinds support program or service.
-- Scripts are provided AS IS without warranty of any kind. SolarWinds further
-- disclaims all warranties including, without limitation, any implied warranties
-- of merchantability or of fitness for a particular purpose. The risk arising
-- out of the use or performance of the scripts and documentation stays with you.
-- In no event shall SolarWinds or anyone else involved in the creation,
-- production, or delivery of the scripts be liable for any damages whatsoever
-- (including, without limitation, damages for loss of business profits, business
-- interruption, loss of business information, or other pecuniary loss) arising
-- out of the use of or inability to use the scripts or documentation.
UPDATE NodesData
SET PollInterval = 120
WHERE PollInterval = 0;
UPDATE NodesData
SET RediscoveryInterval = 30
WHERE RediscoveryInterval = 0;
Step 2: Fix Historical Records with Invalid Weight
Update the historical CPU performance tables to replace any NULL or 0 Weight values with a valid default (e.g., 120).
-- Scripts are not supported under any SolarWinds support program or service.
-- Scripts are provided AS IS without warranty of any kind. SolarWinds further
-- disclaims all warranties including, without limitation, any implied warranties
-- of merchantability or of fitness for a particular purpose. The risk arising
-- out of the use or performance of the scripts and documentation stays with you.
-- In no event shall SolarWinds or anyone else involved in the creation,
-- production, or delivery of the scripts be liable for any damages whatsoever
-- (including, without limitation, damages for loss of business profits, business
-- interruption, loss of business information, or other pecuniary loss) arising
-- out of the use of or inability to use the scripts or documentation.
UPDATE CPUMultiLoad_CS_Detail_hist
SET Weight = 120
WHERE Weight IS NULL OR Weight = 0;
UPDATE CPULoad_CS_Detail_hist
SET Weight = 120
WHERE Weight IS NULL OR Weight = 0;
Step 3: Allow the Next Database Maintenance Cycle to Run
After applying the above fixes, allow the scheduled database maintenance task to run. It should now complete without triggering divide-by-zero errors.