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

Enable global checkpoint listeners to timeout #33620

Merged

Conversation

@jasontedor
Copy link
Member

commented Sep 12, 2018

In cross-cluster replication, we will use global checkpoint listeners to long poll for updates to a shard. However, we do not want these polls to wait indefinitely as it could be difficult to discern if the listener is still waiting for updates versus something has gone horribly wrong and cross-cluster replication is stuck. Instead, we want these listeners to timeout after some period (for example, one minute) so that they are notified and we can update status on the following side that cross-cluster replication is still active. After this, we will immediately enter back into a poll mode.

To do this, we need the ability to associate a timeout with a global checkpoint listener. This commit adds this capability.

Relates #32696

Enable global checkpoint listeners to timeout
In cross-cluster replication, we will use global checkpoint listeners to
long poll for updates to a shard. However, we do want these polls to
wait indefinitely as it could be difficult to discern if the listener is
still waiting for updates versus something has gone horribly wrong and
cross-cluster replication is stuck. Instead, we want these listeners to
timeout after some period (for example, one minute) so that they are
notified and we can update status on the following side that
cross-cluster replication is still active. After this, we will
immediately enter back into a poll mode.

To do this, we need the ability to associate a timeout with a global
checkpoint listener. This commit adds this capability.
@elasticmachine

This comment has been minimized.

Copy link
Collaborator

commented Sep 12, 2018

jasontedor added 2 commits Sep 12, 2018
@bleskes
Copy link
Member

left a comment

LGTM. Left some nits to accept or reject.

logger.warn("error notifying global checkpoint listener of closed shard", caught);
} else {
assert e instanceof TimeoutException : e;
logger.warn("error notifying global checkpoint listener of timeout", caught);

This comment has been minimized.

Copy link
@bleskes

bleskes Sep 12, 2018

Member

nit: why not just always log the exception (to serve as an indicator of what happened) and assert its either IndexShardCloseException or TimeoutException?

This comment has been minimized.

Copy link
@jasontedor

jasontedor Sep 12, 2018

Author Member

I prefer it as since it's more explicit, and since your approach only saves two lines of code I'll stick with mine. 😇

jasontedor added 2 commits Sep 12, 2018
@jasontedor

This comment has been minimized.

Copy link
Member Author

commented Sep 12, 2018

Thanks @bleskes, will merge on green.

@martijnvg
Copy link
Member

left a comment

LGTM

@dnhatn
dnhatn approved these changes Sep 12, 2018
Copy link
Contributor

left a comment

LGTM.

}

// guarded by this
private boolean closed;
private volatile List<GlobalCheckpointListener> listeners;
private volatile Map<GlobalCheckpointListener, ScheduledFuture<?>> listeners;

This comment has been minimized.

Copy link
@dnhatn

dnhatn Sep 12, 2018

Contributor

afaics, all accesses to listeners are under lock, but I may miss something.

This comment has been minimized.

Copy link
@jasontedor

jasontedor Sep 12, 2018

Author Member

You're right, good catch @dnhatn. In an early version of #32696 this was not the case but during review we changed it so that it is the case, and then missed that volatile is no longer necessary here. I will remove this in a follow-up.

@jasontedor jasontedor merged commit 36ba3cd into elastic:master Sep 12, 2018

5 checks passed

CLA Commit author is a member of Elasticsearch
Details
elasticsearch-ci Build finished.
Details
elasticsearch-ci/java11 Build finished.
Details
elasticsearch-ci/oss-distro-docs Build finished.
Details
elasticsearch-ci/packaging-sample Build finished.
Details
jasontedor added a commit that referenced this pull request Sep 12, 2018
Enable global checkpoint listeners to timeout (#33620)
In cross-cluster replication, we will use global checkpoint listeners to
long poll for updates to a shard. However, we do not want these polls to
wait indefinitely as it could be difficult to discern if the listener is
still waiting for updates versus something has gone horribly wrong and
cross-cluster replication is stuck. Instead, we want these listeners to
timeout after some period (for example, one minute) so that they are
notified and we can update status on the following side that
cross-cluster replication is still active. After this, we will
immediately enter back into a poll mode.

To do this, we need the ability to associate a timeout with a global
checkpoint listener. This commit adds this capability.

@jasontedor jasontedor deleted the jasontedor:global-checkpoint-listener-timeout branch Sep 12, 2018

@colings86 colings86 added the >bug label Oct 25, 2018

@colings86 colings86 added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.