Skip to content

roachpb: surface more accurate bytes scattered in AdminScatterResponse#80338

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
adityamaru:fix-combine
May 2, 2022
Merged

roachpb: surface more accurate bytes scattered in AdminScatterResponse#80338
craig[bot] merged 1 commit intocockroachdb:masterfrom
adityamaru:fix-combine

Conversation

@adityamaru
Copy link
Copy Markdown
Contributor

This change approximates the byte size of all the replicas that
were moved as part of an AdminScatter request by comparing their
store IDs before and after the replicas are passed through the
replicate queue.

This change also fixes a bug where MVCCStats returned as part of the
AdminScatterResponse were not being combined. This would cause
misrepresentation of the stats if the scatter key span covered
more than one range.

Release note: None

@adityamaru adityamaru requested a review from a team as a code owner April 21, 2022 21:28
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@adityamaru
Copy link
Copy Markdown
Contributor Author

Going to tag on a commit that changes the adder and batcher to use the new field, should we nuke the MVCCStats from the response unless we think we'll need it in the future @dt?

Copy link
Copy Markdown
Contributor

@aayushshah15 aayushshah15 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @adityamaru, @andreimatei, and @dt)


pkg/kv/kvserver/replica_command.go, line 3435 at r1 (raw file):

		RangeInfos: []roachpb.RangeInfo{ri},
		MVCCStats:  stats,
		// Note, we use this range's MVCCStats to estimate the size of the replicas

This replica's*

@aayushshah15
Copy link
Copy Markdown
Contributor

pkg/kv/kvserver/replica_command.go, line 3419 at r1 (raw file):

	// Compute how many replicas of this range were moved by the replicate queue.
	var numReplicasMoved int
	for _, rd := range r.Desc().Replicas().Descriptors() {

Sorry I didn't read this carefully enough before approving. Note that ReplicaIDs are monotonically increasing (as replicas are rebalanced/added) and not some function of the number of replicas (which is what this seems to be assuming).

Essentially what we want is something like

if _, ok := oldStoreIDs[rd.ReplicaID]; !ok {
  numReplicasMoved++
}

Copy link
Copy Markdown
Contributor Author

@adityamaru adityamaru left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @aayushshah15, @andreimatei, and @dt)


pkg/kv/kvserver/replica_command.go, line 3419 at r1 (raw file):

Previously, aayushshah15 (Aayush Shah) wrote…

Sorry I didn't read this carefully enough before approving. Note that ReplicaIDs are monotonically increasing (as replicas are rebalanced/added) and not some function of the number of replicas (which is what this seems to be assuming).

Essentially what we want is something like

if _, ok := oldStoreIDs[rd.ReplicaID]; !ok {
  numReplicasMoved++
}

ahh TIL, thanks


pkg/kv/kvserver/replica_command.go, line 3435 at r1 (raw file):

Previously, aayushshah15 (Aayush Shah) wrote…

This replica's*

Done.

@adityamaru
Copy link
Copy Markdown
Contributor Author

@aayushshah15 going to wait on another stamp from you before borsing

Copy link
Copy Markdown
Contributor

@aayushshah15 aayushshah15 left a comment

Choose a reason for hiding this comment

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

:lgtm: (but I've only reviewed the KV-related parts).

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @aayushshah15, @adityamaru, @andreimatei, and @dt)


pkg/kv/kvserver/replica_command.go line 3365 at r3 (raw file):

	oldStoreIDs := make(map[roachpb.ReplicaID]struct{})
	for _, rd := range r.Desc().Replicas().Descriptors() {
		oldStoreIDs[rd.ReplicaID] = struct{}{}

nit: let's rename this map to something more accurate.

This change approximates the byte size of all the replicas that
were moved as part of an AdminScatter request by comparing their
store IDs before and after the replicas are passed through the
replicate queue.

This change also fixes a bug where MVCCStats returned as part of the
AdminScatterResponse were not being combined. This would cause
misrepresentation of the stats if the scatter key span covered
more than one range.

Release note: None
@adityamaru
Copy link
Copy Markdown
Contributor Author

TFTR!

bors r=aayushshah15

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 2, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 2, 2022

Build succeeded:

@craig craig bot merged commit f5a6c68 into cockroachdb:master May 2, 2022
@adityamaru adityamaru deleted the fix-combine branch May 3, 2022 14:02
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.

3 participants