client/metadata: fix crasher caused by AllowStale = false (#16549)

Fixes #16517

Given a 3 Server cluster with at least 1 Client connected to Follower 1:

If a NodeMeta.{Apply,Read} for the Client request is received by
Follower 1 with `AllowStale = false` the Follower will forward the
request to the Leader.

The Leader, not being connected to the target Client, will forward the
RPC to Follower 1.

Follower 1, seeing AllowStale=false, will forward the request to the
Leader.

The Leader, not being connected to... well hoppefully you get the
picture: an infinite loop occurs.
This commit is contained in:
Michael Schurter
2023-03-20 16:32:32 -07:00
committed by GitHub
parent 695df42d33
commit fb085186b7
13 changed files with 197 additions and 31 deletions

View File

@@ -30,9 +30,9 @@ func (n *Nodes) Meta() *NodeMeta {
// Apply dynamic Node metadata updates to a Node. If NodeID is unset then Node
// receiving the request is modified.
func (n *NodeMeta) Apply(meta *NodeMetaApplyRequest, qo *WriteOptions) (*NodeMetaResponse, error) {
func (n *NodeMeta) Apply(meta *NodeMetaApplyRequest, qo *QueryOptions) (*NodeMetaResponse, error) {
var out NodeMetaResponse
_, err := n.client.post("/v1/client/metadata", meta, &out, qo)
_, err := n.client.postQuery("/v1/client/metadata", meta, &out, qo)
if err != nil {
return nil, err
}