Skip to content

storage: Track renewable expiration-based leases in map instead of chan#28975

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
a-robinson:renewalmap
Aug 27, 2018
Merged

storage: Track renewable expiration-based leases in map instead of chan#28975
craig[bot] merged 1 commit intocockroachdb:masterfrom
a-robinson:renewalmap

Conversation

@a-robinson
Copy link
Copy Markdown
Contributor

As discussed on #28931

Release note: None

@a-robinson a-robinson requested review from a team and petermattis August 22, 2018 20:46
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@a-robinson
Copy link
Copy Markdown
Contributor Author

ping @petermattis

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm:

Thanks for the ping. Somehow missed this.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/storage/store.go, line 432 at r1 (raw file):

	// renew. An object is sent on the signal whenever a new entry is added to
	// the map.
	renewableLeases       syncutil.IntMap // map[roachpb.RangeID]*Replica

I think syncutil.IntMap might be inappropriate here due to the usage pattern. syncutil.IntMap should be used for read-mostly maps. I think a regular map with a mutex is likely better.

On the other hand, there would definitely be more awkwardness with a regular map and a mutex. And the renewableLeases map is stable until a lease changes hands. Ok, I'm fine with this as-is.

Copy link
Copy Markdown
Contributor Author

@a-robinson a-robinson left a comment

Choose a reason for hiding this comment

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

TFTR!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained


pkg/storage/store.go, line 432 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

I think syncutil.IntMap might be inappropriate here due to the usage pattern. syncutil.IntMap should be used for read-mostly maps. I think a regular map with a mutex is likely better.

On the other hand, there would definitely be more awkwardness with a regular map and a mutex. And the renewableLeases map is stable until a lease changes hands. Ok, I'm fine with this as-is.

I chose the sync.Map because it means that insertion and iteration don't interfere with each other. Alternatively we'd have to copy the entire map in each iteration of the loop in startLeaseRenewer in order to avoid holding the lock while calling redirectOnOrAcquireLease on each replica.

And as you mention, this map should actually be read-mostly because writes only occur when a lease changes hands.

@a-robinson
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 27, 2018

Build failed (retrying...)

craig bot pushed a commit that referenced this pull request Aug 27, 2018
28912: kv: teach DistSender about RangeFeeds, use for changefeeds r=nvanbenschoten a=nvanbenschoten

This change adds a RangeFeed method to DistSender and teaches it how
to split rangefeeds across ranges and how to manage their individual
lifecycle events. It then adjusts the changefeed poller to use RangeFeed
requests when the corresponding cluster setting is enabled.

28975: storage: Track renewable expiration-based leases in map instead of chan r=a-robinson a=a-robinson

As discussed on #28931

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 27, 2018

Build succeeded

@craig craig bot merged commit bdf3c5a into cockroachdb:master Aug 27, 2018
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