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

[CCR] Added write buffer size limit #34797

Merged
merged 12 commits into from
Oct 24, 2018

Conversation

martijnvg
Copy link
Member

@martijnvg martijnvg commented Oct 24, 2018

This limit is based on the size in bytes of the operations in the write buffer. If this limit is exceeded then no more read operations will be coordinated until the size in bytes of the write buffer has dropped below the configured write buffer size limit.

Renamed existing max_write_buffer_size to max_write_buffer_count to indicate that limit is count based.

Closes #34705

This limit is based on the size in bytes of the operations in the write buffer. If this limit is exceeded then no more read operations will be coordinated until the size in bytes of the write buffer has dropped below the configured write buffer size limit.

Renamed existing `max_write_buffer_size` to ``max_write_buffer_count` to indicate that limit is count based.

Closes elastic#34705
@martijnvg martijnvg added >non-issue :Distributed Indexing/CCR Issues around the Cross Cluster State Replication features labels Oct 24, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

Copy link
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

This looks great. I left some minor comments.

I noticed that the current implementation (not this PR) might fill the write buffer more than the limit. When we send a read-request, we don't limit the request count and size to the vacant slots of the write buffer. If the buffer has one byte (or one count) left, we still issue a full read-request. We can fix this in a follow-up if we feel we should.

@@ -327,7 +327,7 @@ private void followLeaderIndex(String autoFollowPattenName,
followRequest.setMaxConcurrentReadBatches(pattern.getMaxConcurrentReadBatches());
followRequest.setMaxBatchSize(pattern.getMaxBatchSize());
followRequest.setMaxConcurrentWriteBatches(pattern.getMaxConcurrentWriteBatches());
followRequest.setMaxWriteBufferSize(pattern.getMaxWriteBufferSize());
followRequest.setMaxWriteBufferCount(pattern.getMaxWriteBufferCount());
Copy link
Member

Choose a reason for hiding this comment

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

We forget passing "maxWriteBufferSize" parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

whoops

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed: 7af8ba2

@@ -85,6 +85,7 @@
private long numberOfOperationsIndexed = 0;
private long lastFetchTime = -1;
private final Queue<Translog.Operation> buffer = new PriorityQueue<>(Comparator.comparing(Translog.Operation::seqNo));
private long bufferSize = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Should it be bufferSizeInBytes?

Copy link
Member Author

Choose a reason for hiding this comment

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

renamed: 9925984

@@ -208,6 +213,8 @@ private synchronized void coordinateWrites() {
break;
}
}
long opsSize = ops.stream().mapToLong(Translog.Operation::estimateSize).sum();
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this into the loop to avoid the loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed: 980f1a5

@martijnvg
Copy link
Member Author

@dnhatn Thanks for reviewing!

I noticed that the current implementation (not this PR) might fill the write buffer more than the limit. When we send a read-request, we don't limit the request count and size to the vacant slots of the write buffer. If the buffer has one byte (or one count) left, we still issue a full read-request.

Yes, that is what it is currently doing. I don't see a real problem in the way the limit is currently enforced.

@bleskes
Copy link
Contributor

bleskes commented Oct 24, 2018

Yes, that is what it is currently doing. I don't see a real problem in the way the limit is currently enforced.

+1. The main rationale here was to keep things simple and treat the limit as a soft limit that is used to cause back pressure. No more.

Copy link
Member

@dnhatn dnhatn left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -455,6 +466,7 @@ public synchronized ShardFollowNodeTaskStatus getStatus() {
numConcurrentReads,
numConcurrentWrites,
buffer.size(),
bufferSizeInBytes,
Copy link
Member

Choose a reason for hiding this comment

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

nit: indentation

@dnhatn
Copy link
Member

dnhatn commented Oct 24, 2018

Makes sense. Thanks @martijnvg and @bleskes for explaining.

@martijnvg
Copy link
Member Author

Note that this PR also changes the default for max_write_buffer_count from 10240 to unlimited:
9d642b5

The reason behind this that a finding a default for this parameter is difficult and because this pr add max_write_buffer_size, that will make sure that the write buffer does not accumulate too many write operations.

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

LGTM.

@martijnvg martijnvg merged commit 6fe0e62 into elastic:master Oct 24, 2018
martijnvg added a commit that referenced this pull request Oct 24, 2018
This limit is based on the size in bytes of the operations in the write buffer. If this limit is exceeded then no more read operations will be coordinated until the size in bytes of the write buffer has dropped below the configured write buffer size limit.

Renamed existing `max_write_buffer_size` to ``max_write_buffer_count` to indicate that limit is count based.

Closes #34705
kcm pushed a commit that referenced this pull request Oct 30, 2018
This limit is based on the size in bytes of the operations in the write buffer. If this limit is exceeded then no more read operations will be coordinated until the size in bytes of the write buffer has dropped below the configured write buffer size limit.

Renamed existing `max_write_buffer_size` to ``max_write_buffer_count` to indicate that limit is count based.

Closes #34705
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/CCR Issues around the Cross Cluster State Replication features >non-issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants