Skip to content

Support retry logic for auto recovery#3799

Closed
wolfstudy wants to merge 1 commit into
apache:masterfrom
wolfstudy:xiaolong/add-retry-recovery
Closed

Support retry logic for auto recovery#3799
wolfstudy wants to merge 1 commit into
apache:masterfrom
wolfstudy:xiaolong/add-retry-recovery

Conversation

@wolfstudy

Copy link
Copy Markdown
Member

Descriptions of the changes in this PR:

Motivation

In the current implementation, when the Session between Bookie and ZK expires, Auto Recovery does not support automatic reconnection. However, the bookie server itself supports reconnection logic, so when Auto Recovery and Bookie Server are deployed together, once the Session expires with ZK, Auto Recovery will automatically stop and cause the entire Bookie service to go down.

However, in a production environment, session expiration between Bookie and ZK itself is a high-frequency operation, such as the following scenario:

From the ZK side, we can see that the current ZK zxid has overflowed, triggering XidRolloverException:

image
image

When the above situation occurs, we can see that the Session between Bookie and ZK expires:

image
image

Since Auto Recovery has no reconnection logic, the entire Bookie service is down.

Changes

  • Add retry logic for auto recovery

Signed-off-by: xiaolongran <xiaolongran@tencent.com>
@codecov-commenter

codecov-commenter commented Feb 22, 2023

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.51%. Comparing base (80d3aac) to head (0d22006).
⚠️ Report is 559 commits behind head on master.

Files with missing lines Patch % Lines
.../apache/bookkeeper/replication/AuditorElector.java 25.00% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3799      +/-   ##
============================================
+ Coverage     60.47%   60.51%   +0.03%     
- Complexity     5847     5850       +3     
============================================
  Files           473      473              
  Lines         40933    40937       +4     
  Branches       5235     5237       +2     
============================================
+ Hits          24756    24772      +16     
+ Misses        13976    13951      -25     
- Partials       2201     2214      +13     
Flag Coverage Δ
bookie 39.88% <0.00%> (-0.04%) ⬇️
remaining 29.68% <25.00%> (+<0.01%) ⬆️
replication 41.42% <0.00%> (+0.08%) ⬆️
tls 21.04% <0.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

} catch (Exception e) {
LOG.error("Exception while performing auditor election", e);
submitShutdownTask();
if (e.getCause() instanceof KeeperException.ConnectionLossException

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's better to retry with a delay time I think.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIRC ConnectionLoss is a non-recoverable exception.
To handle it properly, one has to re-create ZK client and deal with the watchers/cached state. Ephemeral nodes expire as result of such error too.
Re-initializing the client at random place when error happens is a rather big chunk of work IIRC and it easier to bounce the service in this case, hence #3374

@zymap zymap Feb 23, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dlg99 I saw it said connection loss is a recoverable exception.

Recoverable errors: the disconnected event, connection timed out, and the connection loss exception are examples of recoverable errors

The session expiration is a fatal error. We should re-create ZK client

@dlg99 dlg99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Please see #3374 and https://cwiki.apache.org/confluence/display/ZOOKEEPER/ErrorHandling
  2. IIRC ConnectionLoss (or SessionExpiredEx or both) is a non-recoverable exception. To handle it properly, one has to re-create ZK client and deal with the watchers/cached state. Ephemeral nodes expire as result of such error too. Re-initializing the client at random place when error happens is a rather big chunk of work IIRC and it easier to bounce the service in this case, hence #3374
  3. Change without unit tests/repro

If you disagree with my assessment please start a discussion in the mailing list.

@eolivelli has deeper knowledge of zookeeper, let's double-check with him too.

It is not a good idea in general to run the autorecovery as part of the bookie in prod. The best practice is to run it as a separate service on either another host (which allows one to have fewer AR service nodes than bookies) or alongside with the bookie as a separate process. Running AR separately also helps with such issues like AR activity resulting in a more frequent java GC cycles. HTH.

} catch (Exception e) {
LOG.error("Exception while performing auditor election", e);
submitShutdownTask();
if (e.getCause() instanceof KeeperException.ConnectionLossException

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIRC ConnectionLoss is a non-recoverable exception.
To handle it properly, one has to re-create ZK client and deal with the watchers/cached state. Ephemeral nodes expire as result of such error too.
Re-initializing the client at random place when error happens is a rather big chunk of work IIRC and it easier to bounce the service in this case, hence #3374

@hangc0276 hangc0276 modified the milestones: 4.16.0, 4.17.0 Mar 13, 2023
@wolfstudy wolfstudy closed this May 4, 2023
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.

5 participants