You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(opensearchtransport): make connection dead/overloaded timestamps lock-free (#892) (#906)
Convert deadSince/overloadedAt from mu-guarded time.Time to lock-free
atomic.Int64 (UnixNano, 0 = unset). Writes still occur under c.mu so the
resurrection/standby read-modify-write decisions stay serialized; only the
reads went lock-free, so buildConnectionMetric no longer takes each
connection's mutex -- the #1 explicit-lock contention site under concurrent
load. Port of the non-breaking perf work from #901; v4 retains EnableMetrics
(unchanged surface and behavior).
Also fix a pre-existing data race in RolePolicy.DiscoveryUpdate, surfaced
while auditing the pool locking. It called recalculateWarmupParams without
holding the pool write lock, while the roundrobin and cluster_coordinator
policies took pool.Lock() for the identical call. recalculateWarmupParams
writes the pool's warmupRounds, warmupSkipCount, and activeListCap fields,
which getWarmupParams and the other DiscoveryUpdate callers read and write
under that same lock, so two concurrent DiscoverNodes calls raced on those
fields. Compute the projected pool size and recalculate warmup parameters
under pool.Lock(), releasing before discoveryUpdateAdd/Remove. Add
TestRolePolicyDiscoveryUpdateConcurrent, which reproduces the race under -race.
Signed-off-by: Ryan Yuan <ryan.yuan@crowdstrike.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
164
164
165
165
### Changed
166
166
167
+
- Connection dead/overloaded timestamps (`deadSince`/`overloadedAt`) are now lock-free `atomic.Int64` values. `buildConnectionMetric` no longer locks each connection to read them, removing the dominant metrics-snapshot lock contention against the per-request writers. No public API change; `EnableMetrics` behavior is unchanged. ([#892](https://github.com/opensearch-project/opensearch-go/issues/892))
167
168
- Per-request transport metrics (`requests`, `failures`, responses-by-status) are now always collected via lock-free atomics, independent of `EnableMetrics`. `EnableMetrics` now gates only the detailed-metrics snapshot (per-connection, per-policy, and router state returned by `Metrics()`). The responses-by-status counter moved from a mutex-guarded map to a lock-free atomic array. `Metrics()` no longer returns an error when metrics are disabled — it always returns the per-request counters (callers that branched on `if err != nil` for the disabled case should drop that check). ([#891](https://github.com/opensearch-project/opensearch-go/issues/891))
168
169
-**BREAKING**: `opensearch.Request` interface signature changed from `GetRequest() (*http.Request, error)` to `GetRequest(method string) (*http.Request, error)`. The HTTP method is now caller-provided rather than hardcoded per operation, enabling correct method selection for operations that support multiple HTTP methods (e.g. search supports both GET and POST). This only affects code that implements or calls `GetRequest` directly; standard usage through client methods (e.g. `client.Search(ctx, req)`) is unaffected ([#650](https://github.com/opensearch-project/opensearch-go/issues/650))
169
170
- Bump CI and developer guide OpenSearch versions: compatibility matrix to 2.19.5, default integration test version to 3.6.0 ([#810](https://github.com/opensearch-project/opensearch-go/pull/810))
0 commit comments