opensearch-go v5.2.1
UPGRADE NOTE - v5.2.1 makes the direct mget driver the default.
DocumentClient.MGetnow splits each mget by shard in the client and sends each node only the documents it holds. The response is the one the cluster's coordinator would have given. An mget the client cannot split, because the transport keeps no shard map (for example withOPENSEARCH_GO_ROUTER=false) or none of its documents can be routed to a node, still goes to the cluster as one request.- To keep sending every mget as one request, as v5.2.0 did, set
MGetConfig.DrivertoMGetDriverCoordinator, setOPENSEARCH_GO_MGET=coordinator, or useopensearchapi.WithMGetDriverper call.Before/after is in
UPGRADING_V5.md.
v5.2.1 makes the direct mget driver the default and adds typed constants for the query parameters that took magic strings.
It fixes the router sending every idle client's bulks to the same node. Previously, the router broke ties by URL; now a bulk goes to the least loaded of a few randomly drawn nodes, and a tie is broken at random, weighted by shard count for a ?routing= list. It also fixes a startup panic and several discovery bugs, bulk items that set Refresh or WaitForActiveShards, and index settings with an untyped analyzer that failed to decode.
Requires Go 1.26.0 or later.
Full Changelog: v5.2.0...v5.2.1
What's new
- Typed constants for enum-valued query parameters, such as
Refresh,ExpandWildcards,Level,WaitForStatus,DefaultOperator,SortOrderandSuggestModeon the core API, and the enum-valued parameters of the Insights, Notifications, Security Analytics and Tasks APIs. The new types are aliases ofstring(and[]stringforExpandWildcards), so code that assigns astringto these fields keeps compiling. Constants also cover the sharedformatparameter and the integer-or-keyword parametersWaitForActiveShards(WaitForActiveShardsAll,WaitForActiveShardsCount(n)) andSlices(SlicesAuto,SlicesCount(n)). Every enum type now says what it controls and its server default (#1355) opensearchapi.DurationUnboundednames "no timeout" fortime.Durationparameters, and a negative duration is sent as-1, which the server accepts. It used to be sent as-1000000nanos, which the server rejects (#1355)
Other changes
DocumentClient.MGetuses the direct driver by default. See the upgrade note above andguides/usage-mget.md(#1298)- Add OpenSearch 3.10.0 to the CI compatibility matrix and make it the default integration test version, replacing 3.9.0. By @sean- in #1370
Fixes
- fix(opensearchtransport): the default router sent every request with no index in its path, such as
POST /_bulk, to the same node. A client sending one bulk at a time has nothing in flight anywhere, so ties broke by URL and every idle client in a fleet picked the node that sorted first. The router now draws two random nodes from the nearest RTT tier and one from the farther tiers, and sends the request to the lowest score among them, with each score weighted by the node's write-coordination rate fromindexing_pressure.NodeStatsgains anIndexingPressurefield. Reported by @sean- in #1363. By @sean- in #1366 - fix(opensearchtransport): the router always chose the same node among candidates with the same score, such as two idle replicas of a shard for
GET /{index}/_doc/{id}. It now chooses among them at random. For a?routing=list, each tied node's chance is proportional to how many of the targeted shards it hosts. A candidate with a better score still wins. By @sean- in #1366 - fix(opensearchapi): the direct mget driver read every mget of a shard from the same copy when the copies were equally idle. Ties between copies are now broken at random. By @sean- in #1366
- fix(opensearchtransport):
Newcould panic with a nil pointer when a seed node failed during startup.NewandNewConnectionPoolcopy the seed slice before building a pool. Reported in #1300. By @Kirollbas in #1304 - fix(opensearchtransport): routing policies lost a node when discovery replaced its connection with a new one at the same URL, for example when a seed became a discovered node.
DiscoveryUpdatenow removes connections by identity, not by URL. Reported in #1301. By @Kirollbas in #1305 - fix(opensearchtransport): node discovery, shard placement and routing metadata requests ignored
RequestTimeout, so a node that sent headers and then stalled held up discovery until the caller's deadline. A positiveRequestTimeoutnow bounds each of them. Reported in #1302. By @Kirollbas in #1306 - fix(opensearchtransport): on clusters with many or long index names, the routing metadata request could exceed the server's default 4096-byte
http.max_initial_line_length. It is now split into requests that fit. Reported in #1303. By @Kirollbas in #1307 - fix(opensearchtransport):
Transport.Requestreported a node healthy when its response body failed to read. The body is now read inside each attempt, so a truncated or stalled body fails the node and a read-only request is retried on another node. When the request is not retried, the error matchesErrResponseBodyRead. Reported by @Kirollbas in #1296 (#1299) - fix(opensearchutil): bulk items that set
BulkIndexerItem.RefreshorBulkIndexerItem.WaitForActiveShardswere rejected by the server, because the client wrote both into the action line. It no longer sends them (#1355) - fix(osgen): an analyzer or normalizer with no
typenow decodes ascustom, as OpenSearch treats it.Indices.Getand other responses that carry index analysis settings used to fail withpayload has no type discriminator(#1297) - fix(osgen):
NewCommonMappingPropertyFromBinaryPropertyandNewCommonMappingPropertyFromMatchOnlyTextPropertyleftTypeempty, so OpenSearch rejected the mapping. Reported by @joshuar in #1336. By @SudeepGowda55 in #1337 - Add a copy of
LICENSE.txtto each nested module, so pkg.go.dev detects their license and shows their documentation (#1297)
Deprecations
BulkIndexerItem.RefreshandBulkIndexerItem.WaitForActiveShards. The server accepts neither in a bulk action line. UseBulkIndexerConfig.RefreshandBulkIndexerConfig.WaitForActiveShards(#1355)
Dependencies
- Update the
toolchainline to go1.26.11 in the root and all nested modules. The go directive stays 1.26.0, so consumers are not affected (#1360) - Pin every nested module to the v5.2.1 root module (#1377)
See CHANGELOG.md for the full list.
Contributors
Thanks to everyone who contributed to this release: @Kirollbas, @SudeepGowda55, @sean- and @ryanyuan.
Thanks to @Kirollbas for reporting five transport bugs and fixing four of them, and to @joshuar for reporting the empty Type in the mapping property constructors.