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

Prevent write timeouts due to lock contention in WAL #3886

Merged
merged 3 commits into from
Aug 28, 2015
Merged

Prevent write timeouts due to lock contention in WAL #3886

merged 3 commits into from
Aug 28, 2015

Conversation

jwilder
Copy link
Contributor

@jwilder jwilder commented Aug 28, 2015

When disk operations slow down or the amount of work required to flush writes to the index takes too long, the lock contention on the WAL can cause timeouts for writes. The PR reduces some the contention for some of the locks when these timeouts occur and prevents write timeouts in scenarios.

@otoolep
Copy link
Contributor

otoolep commented Aug 28, 2015

Seems reasonable.

partitionsToWrite := l.pointsToPartitions(points)
l.mu.RUnlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Any point adding a comment.....// persist the raw point data, holding the lock for as short as possible.

I am a little concerned future developers would revert to defer. We're adding some important changes, but it may not be obvious why in the future.

@otoolep
Copy link
Contributor

otoolep commented Aug 28, 2015

Probably worthy of a CHANELOG addition, mentioning it reduces the number of timeouts during writes, so the community knows there is a reason for improvements they might see (and that they are not imagining it).

The log was deferring the release of the read lock on the WAL.  This had
the affect that a read-lock was held until after the partition finished writing
(which maintains it's own locks).  The read lock is only needed around the call
to pointsToPartions so it can get a consistent copy of the points to write.  After
that calls returns, a lock is not needed so free it immediatedly.
A write lock was being taken to read the memory size to determine if writes
should be paused.  What happens is that writers get blocked indefintely when
trying to acquire a write lock which makes writes pause (or stop) for long periods
of time.
@pauldix
Copy link
Member

pauldix commented Aug 28, 2015

+1

jwilder added a commit that referenced this pull request Aug 28, 2015
Prevent write timeouts due to lock contention in WAL
@jwilder jwilder merged commit b745d63 into master Aug 28, 2015
@jwilder jwilder deleted the jw-wal branch August 28, 2015 21:26
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.

None yet

3 participants