Skip to content

HA: Always check realization context deadline#1138

Open
oxzi wants to merge 1 commit into
mainfrom
ha-realize-ctx-deadline-exceeded
Open

HA: Always check realization context deadline#1138
oxzi wants to merge 1 commit into
mainfrom
ha-realize-ctx-deadline-exceeded

Conversation

@oxzi

@oxzi oxzi commented Jun 24, 2026

Copy link
Copy Markdown
Member

The HA realization logic is bound to a context with a deadline based on the latest heartbeat message expiration time. Within the realize method, a database transaction is used - also honoring this context - within a retry.WithBackoff wrapper.

The retry.WithBackoff function returns the inner function's error, even when the context's deadline has exceeded. While this is intentional and useful, it might hide a relation to a context issue.

In this case, the exceeding context cancels the database transaction, resulting in a PostgreSQL cancellation, which is being returned as an error on its own.

pq: canceling statement due to user request (57014)

When returning from the realize method, only the error is inspected, not the context with the deadline. Thus, the special case for an exceeded deadline is being skipped in this case.


Fixes #1137. This comment in the issue explains a bit more about the reasoning.

I would be happy if you, @IPB-DevOps, are able to test this PR (in a non-production setup). Same goes for you, @nilmerg.

@oxzi oxzi added this to the 1.6.0 milestone Jun 24, 2026
@cla-bot cla-bot Bot added the cla/signed label Jun 24, 2026
@oxzi oxzi force-pushed the ha-realize-ctx-deadline-exceeded branch from 79e500a to 6216701 Compare June 24, 2026 11:24
The HA realization logic is bound to a context with a deadline based on
the latest heartbeat message expiration time. Within the realize method,
a database transaction is used - also honoring this context - within a
retry.WithBackoff wrapper.

The retry.WithBackoff function returns the inner function's error, even
when the context's deadline has exceeded. While this is intentional and
useful, it might hide a relation to a context issue.

In this case, the exceeding context cancels the database transaction,
resulting in a PostgreSQL cancellation, which is being returned as an
error on its own.

> pq: canceling statement due to user request (57014)

When returning from the realize method, only the error is inspected, not
the context with the deadline. Thus, the special case for an exceeded
deadline is being skipped in this case.
@oxzi oxzi force-pushed the ha-realize-ctx-deadline-exceeded branch from 6216701 to 4f47eb8 Compare June 24, 2026 11:28
@oxzi oxzi changed the title HA: Allow realizeCtx to exceed its deadline HA: Always check realization context deadline Jun 24, 2026
@oxzi oxzi marked this pull request as ready for review June 24, 2026 11:29
@oxzi oxzi added the area/ha label Jun 24, 2026
@oxzi oxzi requested a review from yhabteab June 24, 2026 11:31
@oxzi oxzi moved this from Todo to In progress in Icinga Notifications 1.0 Jun 30, 2026
@oxzi oxzi self-assigned this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

PostgreSQL: HA exited with an error 011error="HA aborted: can't perform "INSERT INTO icingadb_instance"

1 participant