Fix flaky BWC knn query serialization by gating on stream version - #3423
Fix flaky BWC knn query serialization by gating on stream version#3423vlmkoa wants to merge 1 commit into
Conversation
Gate optional-field serialization on the transport stream version instead of the cluster minimum version, so writer and reader always agree during rolling upgrades and the byte stream no longer desyncs (unexpected byte [0x05]). Matches the existing RescoreParser pattern. Fixes opensearch-project#1622 Signed-off-by: Ryan <minhkhoavole@gmail.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
Hi @jmazanec15. I have investigated the issue. The root cause is that the optional field serialization of KNNQueryBuilder is controlled by the cluster minimum version rather than the transport stream version. I fixed it by let StreamInput#getVersion()/StreamOutput#getVersion() instead, matching the pattern that RescoreParser uses. I also added a regression test that isolates the divergence by holding the stream version fixed while varying the mocked cluster-min view. |
What does this PR do?
Gates
KNNQueryBuilder's optional-field serialization on the transport stream version(
StreamInput#getVersion()/StreamOutput#getVersion()) instead of the clusterminimum version, so the writing and reading nodes always agree on the wire format during
a rolling upgrade. Also fixes the two internal delegations to
MethodParametersParserin
KNNQueryBuilderParser, which were hardcoding the cluster-version predicate insteadof forwarding the one passed in.
Why was this PR needed?
During a rolling upgrade, cluster state propagates asynchronously, so two communicating
nodes can transiently hold different views of
KNNClusterUtil#getClusterMinVersion().The writer and reader then disagree on whether a given optional field is present on the
wire, desyncing the byte stream. A later
readBoolean()inSearchSourceBuilderlandson a stray byte, producing the flaky
unexpected byte [0x05]500 error reported in #1622.The fix uses the transport stream version instead, which is negotiated per connection and
is always identical on both ends — matching the pattern already used by
RescoreParserin the same package.
What are the relevant issue numbers?
Closes #1622
Does this PR meet the acceptance criteria?
KNNQueryBuilderRollingUpgradeSerializationTests)