Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvserver: skip non-live nodes when considering candidates for transfers #55808

Merged
merged 1 commit into from
Nov 12, 2020

Conversation

knz
Copy link
Contributor

@knz knz commented Oct 21, 2020

(This PR is forked off #55460 to simplify the discussion. I believe there's no discussion left here? Maybe I can merge it directly?)

Fixes #55440.

Prior to this patch, 3 components could attempt to transfer a replica
to a node currently being drained:

  • the store rebalancer, which rebalances replicas based on disk
    usage and QPS.
  • the allocator, to place new replicas.
  • the allocator, to rebalance replicas depending on load.

This commit introduces a consideration for node liveness when building
the list of candidates, to detect whether a target node is
acceptable. Any node that is not LIVE according to its liveness status
is not considered for a transfer.

Release note (bug fix): In some cases CockroachDB would attempt to
transfer ranges to nodes in the process of being decommissioned or
being shut down; this could cause disruption the moment the node
did actually terminate. This bug has been fixed. It had been
introduced some time before v2.0.

@knz knz requested review from andreimatei and tbg October 21, 2020 11:16
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: if there weren't any unresolved comments on the diff in the original PR.

Reviewed 7 of 7 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei and @knz)


pkg/kv/kvserver/store_rebalancer.go, line 675 at r1 (raw file):

	}

	// If the target store is on a separate node, we will also care

This probably does fix replicate/wide, though not the general problem underlying it. I think the roachtest always ends up wanting to move replicas to a dead node, which will be prevented by your new check. Though it could still end up wanting to move data to another live node in theory. I shall validate.

// TestAllocateCandidatesExcludeDrainingNodes checks that draining nodes,
// as per a store pool's isNodeValidForRoutineReplicaTransfer(),
// are excluded from the list of candidates for an allocation.
func TestAllocateCandidatesExcludeDrainingNodes(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there's nothing particular about draining here. You're testing the isNodeReadyFor.... method. Maybe TestAllocateCandidatesExcludeNonReadyNodes.

@tbg
Copy link
Member

tbg commented Oct 21, 2020

What has me confused is that I think you made this PR primarily for draining nodes, but are you really changing anything for draining nodes? I think a draining node will show up as LIVE, won't it?

func LivenessStatus(
l kvserverpb.Liveness, now time.Time, deadThreshold time.Duration,
) kvserverpb.NodeLivenessStatus {
if l.IsDead(now, deadThreshold) {
if !l.Membership.Active() {
return kvserverpb.NodeLivenessStatus_DECOMMISSIONED
}
return kvserverpb.NodeLivenessStatus_DEAD
}
if !l.Membership.Active() {
return kvserverpb.NodeLivenessStatus_DECOMMISSIONING
}
if l.Draining {
return kvserverpb.NodeLivenessStatus_UNAVAILABLE
}
if l.IsLive(now) {
return kvserverpb.NodeLivenessStatus_LIVE
}
return kvserverpb.NodeLivenessStatus_UNAVAILABLE
}

The concept of draining seems wholly unconnected to the NodeLivenessStatus.

Copy link
Contributor Author

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you really changing anything for draining nodes? I think a draining node will show up as LIVE, won't it?

no it shows as unavailable: see, if l.Draining comes before l.IsLive.

Is this ready to merge?

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei and @tbg)


pkg/kv/kvserver/allocator_test.go, line 2460 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

nit: there's nothing particular about draining here. You're testing the isNodeReadyFor.... method. Maybe TestAllocateCandidatesExcludeNonReadyNodes.

Renamed.


pkg/kv/kvserver/store_rebalancer.go, line 675 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

This probably does fix replicate/wide, though not the general problem underlying it. I think the roachtest always ends up wanting to move replicas to a dead node, which will be prevented by your new check. Though it could still end up wanting to move data to another live node in theory. I shall validate.

Yes agreed.

@knz knz force-pushed the 20201021-rebalance branch from ff76faf to b398d4d Compare October 23, 2020 16:34
Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it shows as unavailable: see, if l.Draining comes before l.IsLive.

Oh, missed that, thanks.

LGTM, though can you update the comment on NODE_STATUS_UNAVAILABLE to indicate that a draining node falls into this category?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @andreimatei and @tbg)

@tbg tbg self-requested a review October 30, 2020 11:40
Prior to this patch, 3 components could attempt to transfer a replica
to a node currently being drained:

- the store rebalancer, which rebalances replicas based on disk
  usage and QPS.
- the allocator, to place new replicas.
- the allocator, to rebalance replicas depending on load.

This commit introduces a consideration for node liveness when building
the list of candidates, to detect whether a target node is
acceptable. Any node that is not LIVE according to its liveness status
is not considered for a transfer.

Release note (bug fix): In some cases CockroachDB would attempt to
transfer ranges to nodes in the process of being decommissioned or
being shut down; this could cause disruption the moment the node
did actually terminate. This bug has been fixed. It had been
introduced some time before v2.0.
@knz knz force-pushed the 20201021-rebalance branch from b398d4d to ffa0ce3 Compare November 12, 2020 17:40
Copy link
Contributor Author

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though can you update the comment on NODE_STATUS_UNAVAILABLE to indicate that a draining node falls into this category?

Done.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @andreimatei and @tbg)

@knz
Copy link
Contributor Author

knz commented Nov 12, 2020

bors r=tbg

@craig
Copy link
Contributor

craig bot commented Nov 12, 2020

This PR was included in a batch that was canceled, it will be automatically retried

@craig
Copy link
Contributor

craig bot commented Nov 12, 2020

Build succeeded:

@craig craig bot merged commit a5e67b6 into cockroachdb:master Nov 12, 2020
@knz knz deleted the 20201021-rebalance branch November 13, 2020 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kverserver: store rebalancer pushes leases back to draining nodes
3 participants