postgres-operator/pkg/util
Thomas Rosenstein 0affa9425a Improve sync responsiveness with background execution and context cancellation
This change improves the responsiveness of the operator when handling
deletion requests by running sync operations in the background and
using context cancellation to interrupt stuck operations.

Changes:
- Add context field to Cluster struct, passed through New()
- Add Cancel() method to cancel cluster's context
- Add StartSync/EndSync/NeedsResync for managing background sync state
- Run Sync() in a background goroutine so worker can process other events
- Add context-aware DB connection methods (initDbConnWithContext)
- Add RetryWithContext() that respects context cancellation
- Cancel cluster context immediately when DeletionTimestamp detected
- Use context-aware connections in syncRoles/syncDatabases
- StartSync/NeedsResync check context cancellation to prevent new syncs
  during deletion (no need for separate deleted flag)

Flow:
1. Sync event spawns background goroutine and returns immediately
2. If another sync arrives while one is running, needsResync flag is set
3. When sync completes, it checks needsResync and requeues if needed
4. Delete cancels context -> stuck DB operations return early -> mutex released
5. StartSync/NeedsResync return false when context cancelled
6. Delete proceeds without waiting for slow/stuck sync operations
2025-12-14 20:43:53 +00:00
..
config bump to v1.15.0 (#2965) 2025-10-21 11:56:33 +02:00
constants Add support for EBS CSI Driver (#2677) 2024-12-19 12:32:09 +01:00
filesystems Fix golint warnings 2017-08-01 16:08:56 +02:00
httpclient use relative path instead of $PWD for go:generate (for go 1.17 compatibility) (#1615) 2021-09-14 14:54:41 +02:00
k8sutil reflect linter feedback, remove unused argumnents and redundant type from arrays (#2739) 2024-08-27 17:56:07 +02:00
nicediff End 2 End tests speedup (#1180) 2020-10-28 10:04:33 +01:00
patroni Extend MaintenanceWindows parameter usage (#2810) 2025-01-15 18:04:36 +01:00
retryutil Improve sync responsiveness with background execution and context cancellation 2025-12-14 20:43:53 +00:00
ringlog fix comments for ringlogger 2017-09-26 13:12:38 +02:00
teams add test team member (#1842) 2022-04-14 10:02:54 +02:00
users skip db user actions when its secret failed to sync on update (#2969) 2025-11-05 16:28:37 +01:00
volumes bump to v1.15.0 (#2965) 2025-10-21 11:56:33 +02:00
util.go fix golangci-lint issues (#2715) 2024-08-14 12:54:44 +02:00
util_test.go add unit test and documentation for finalizers (#2509) 2024-01-22 12:13:40 +01:00