Skip to content

fix(polling): record poller_id in plugin_thold_host_failed - #866

Merged
bmfmancini merged 1 commit into
Cacti:developfrom
bmfmancini:fix/host-failed-poller-id
Nov 6, 2026
Merged

bmfmancini merged 1 commit into
Cacti:developfrom
bmfmancini:fix/host-failed-poller-id

Conversation

@bmfmancini

Copy link
Copy Markdown
Member

Description

With remote storage (remote_storage_method = 1), thold_update_host_status() reads and deletes plugin_thold_host_failed rows WHERE poller_id = $config['poller_id']. The rebuild at the end of the run inserted only host_id:

db_execute("INSERT INTO plugin_thold_host_failed
	(host_id)
	VALUES $failed_ids");

So every row took the column default of 1. On any poller other than 1, its own rows were never read back, so recovery notices for its devices were lost. Its pre-rebuild DELETE … WHERE poller_id = ? never matched them either, so the rows piled up every cycle.

This PR inserts this poller's id with each row. In remote-storage mode the device query is already limited to this poller. In central mode the table is read without a poller filter, so the stored value changes nothing there.

Related Issue

There's no existing issue; I found this while working on #737. I'm happy to open one if you'd like.

Motivation and Context

On a distributed install with remote storage, devices on remote pollers never get recovery notifications.

How Has This Been Tested?

Unit tests (Pest): a new HostFailedPollerIdTest covers a remote poller recording its own id, and the main poller recording 1. Both fail without the change, and the full suite passes with it.

Test server: Cacti 1.2.32, PHP 8.4, with this exact commit deployed. The test server has a single poller, so a test device was assigned to poller_id = 2 and marked down. remote_storage_method was set to 1 for the few seconds of the test (only thold reads it), then restored. thold_update_host_status() was then run twice as poller 2:

develop this PR
Rows after run 1 1, poller_id=1 1, poller_id=2
Rows after run 2 2, poller_id=1,1 (piling up) 1, poller_id=2 (replaced)

This simulates a second poller rather than running a real one.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation repository accordingly.

With remote storage (remote_storage_method = 1),
thold_update_host_status() reads and deletes plugin_thold_host_failed
rows WHERE poller_id = $config['poller_id']. The rebuild at the end of
the run inserted only host_id, so every row took the column default of
1. On any poller other than 1 its own rows were never read back:
recovery notices for its devices were lost, and since its pre-rebuild
DELETE never matched them either, the rows piled up every cycle.

Insert this poller's id with each row. In remote-storage mode the device
query is already limited to this poller; in central mode the table is
read without a poller filter, so the stored value changes nothing there.
Copilot AI balanced review requested due to automatic review settings November 6, 2026 05:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blockers found. The full suite passes on Linux/PHP 8.4; PHP 8.2–8.4 CI is green.

@bmfmancini
bmfmancini merged commit fa01a54 into Cacti:develop Nov 6, 2026
5 checks passed
@bmfmancini
bmfmancini deleted the fix/host-failed-poller-id branch November 6, 2026 22:45
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.

3 participants