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

When corruption strikes, don't create exceptions with circular references #8331

Closed
wants to merge 2 commits into from

Conversation

rmuir
Copy link
Contributor

@rmuir rmuir commented Nov 3, 2014

No description provided.

current = corruptedEngine.get();
assert current != null;
current.addSuppressed(e);
if (current == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this possible? we have a corruptedEngine.compareAndSet above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the situation, as noted in the comment is this:

e = SomeException
ce = ExceptionsHelper.unwrap(e, CorruptIndexException.class)

when current was 'null' for the CAS operation, we know that either ce == e or that ce is the root cause of e that was unwrapped, so we cannot ce.addSuppressed(e) or it creates a cycle.

@bleskes
Copy link
Contributor

bleskes commented Nov 3, 2014

good catch. Left one comment...

@rmuir
Copy link
Contributor Author

rmuir commented Nov 3, 2014

I tried to give a better explanation. after we compareAndSet current, we are just testing if current was previously unset (null). In that case its either e itself or from the initCause hierarchy of e, so we can't add e as a suppressed exception to it. Otherwise, if current was set, then its a separate exception alltogether, so we can safely addSuppressed.

@rmuir
Copy link
Contributor Author

rmuir commented Nov 3, 2014

I tried to simplify the code here so its more intuitive: @bleskes is this easier to grok?

@s1monw
Copy link
Contributor

s1monw commented Nov 3, 2014

LGTM

@bleskes
Copy link
Contributor

bleskes commented Nov 3, 2014

@rmuir I missed the removal of current=corruptedEngine.get(). The new version is anyway much better. Thx and sorry for the noise. LGTM.

@rmuir rmuir closed this in 3c72073 Nov 3, 2014
rmuir added a commit that referenced this pull request Nov 3, 2014
rmuir added a commit that referenced this pull request Nov 3, 2014
@clintongormley clintongormley changed the title when corruption strikes, don't create exceptions with circular references Internal: When corruption strikes, don't create exceptions with circular references Nov 4, 2014
@clintongormley clintongormley changed the title Internal: When corruption strikes, don't create exceptions with circular references When corruption strikes, don't create exceptions with circular references Jun 7, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants