Skip to content

failover: implement offline detection, reuse active connection and connection expiration - #8982

Open
pbrezina wants to merge 43 commits into
SSSD:failoverfrom
pbrezina:fo-offline
Open

failover: implement offline detection, reuse active connection and connection expiration#8982
pbrezina wants to merge 43 commits into
SSSD:failoverfrom
pbrezina:fo-offline

Conversation

@pbrezina

@pbrezina pbrezina commented Jul 21, 2026

Copy link
Copy Markdown
Member

This PR implements three missing functionality, they all depends on the previous patches so I'm sending it in single PR.

  • Now we track the failover state (disconnected, connected, offline), if there are not servers the failover context goes offline, clearing the active server and connection. (Right now there is no automatic recover, TBD in other PR, it is tracked in different ticket).
  • If connection can be reused we reuse it.
  • The LDAP connection can be terminated when expired or idle
  • Various fixes of issues found by AI reviewer

@pbrezina pbrezina changed the title fo offline failover: implement offline detection Jul 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a connection state machine (enum sss_failover_state) to track the failover context's status (DISCONNECTED, CONNECTED, or OFFLINE). It implements offline marking capabilities, updates transactions to return ERR_OFFLINE when no servers are available, and significantly improves robustness by adding numerous out-of-memory (OOM) checks for talloc_reference operations. I have no additional feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@pbrezina
pbrezina force-pushed the fo-offline branch 4 times, most recently from 4b7e387 to 4dd9f94 Compare July 22, 2026 10:12
@pbrezina pbrezina changed the title failover: implement offline detection failover: implement offline detection, reuse active connection and connection expiration Jul 22, 2026
@pbrezina
pbrezina force-pushed the fo-offline branch 3 times, most recently from c357995 to 04266f6 Compare July 23, 2026 16:58
@pbrezina
pbrezina marked this pull request as ready for review July 23, 2026 16:58
@pbrezina

Copy link
Copy Markdown
Member Author

@alexey-tikhonov @justin-stephenson I think this is ready for review. It is a pile of commits, but they are well organized and very small. It's actually less then 1000 lines of code.

@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Jul 29, 2026
Comment thread src/providers/failover/ldap/failover_ldap_connect.c
Comment thread src/providers/failover/failover.c
Comment thread src/providers/failover/failover.c
Comment thread src/providers/failover/failover.c
ERR_NO_MORE_SERVERS is translated to ERR_OFFLINE as the failover context
is set to an offline state and this is a clearer message.
This was previously omitted.
This is a helper to get reference to the active server.
The original idea was that kinit and connect will be always called and
the decision to reuse existing connection will be here. But this is
unnecessary difficult, it can be reused as long as the connection works
and the very simple logic has been implemented in the transaction code.

The LDAP connection code will however implement expiration and idle
timers in subsequent commits.
Be more explicit on the exact place where the current connection was
dropped. This simplifies the logic and state maintenance.

Also add debug messages around reference handling.
This is just for information purpose (backend may choose to set a flag
in the connection), the actually disconnect must happen in a talloc
destructor.
It makes sense to unify the naming pattern as
"sss_failover_active_server_*" when we have multiple functions now.
It makes sense to unify the naming pattern as
"sss_failover_connection_*" when we have multiple functions now.
These helpers compare what we want to remove to what is stored and only
removes the active server or connection if there is a match to avoid
removing active server or connection if it was set to something else
in the mean time.
This is not strictly needed as the connection is terminated by the
sdap_handle destructor which is called automatically when the connection
is being freed, but it is better to be explicit about it.
This will be used to determine whether the connection is idle or busy.

@justin-stephenson justin-stephenson 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.

I will probably have more questions later after implementing this but so far it LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants