Skip to content

Commit

Permalink
avoid init WriteSet when waitForWriteSetMs < 0. (#3325)
Browse files Browse the repository at this point in the history
### Motivation
Avoid init WriteSet when waitForWriteSetMs < 0.
And LedgerHandleAdv didn't recycle WriteSet.
  • Loading branch information
horizonzy authored Jul 26, 2022
1 parent ded05aa commit cb70194
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -878,13 +878,15 @@ CompletableFuture<LedgerEntries> readEntriesInternalAsync(long firstEntry,
// Naturally one of the solutions would be to submit smaller batches and in this case
// current implementation will prevent next batch from starting when bookie is
// unresponsive thus helpful enough.
DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(firstEntry);
try {
if (!waitForWritable(ws, ws.size() - 1, clientCtx.getConf().waitForWriteSetMs)) {
op.allowFailFastOnUnwritableChannel();
if (clientCtx.getConf().waitForWriteSetMs >= 0) {
DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(firstEntry);
try {
if (!waitForWritable(ws, ws.size() - 1, clientCtx.getConf().waitForWriteSetMs)) {
op.allowFailFastOnUnwritableChannel();
}
} finally {
ws.recycle();
}
} finally {
ws.recycle();
}

if (isHandleWritable()) {
Expand Down Expand Up @@ -1343,13 +1345,15 @@ public String toString() {
return;
}

DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(op.getEntryId());
try {
if (!waitForWritable(ws, 0, clientCtx.getConf().waitForWriteSetMs)) {
op.allowFailFastOnUnwritableChannel();
if (clientCtx.getConf().waitForWriteSetMs >= 0) {
DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(op.getEntryId());
try {
if (!waitForWritable(ws, 0, clientCtx.getConf().waitForWriteSetMs)) {
op.allowFailFastOnUnwritableChannel();
}
} finally {
ws.recycle();
}
} finally {
ws.recycle();
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,15 @@ public String toString() {
return;
}

if (!waitForWritable(distributionSchedule.getWriteSet(op.getEntryId()),
0, clientCtx.getConf().waitForWriteSetMs)) {
op.allowFailFastOnUnwritableChannel();
if (clientCtx.getConf().waitForWriteSetMs >= 0) {
DistributionSchedule.WriteSet ws = distributionSchedule.getWriteSet(op.getEntryId());
try {
if (!waitForWritable(ws, 0, clientCtx.getConf().waitForWriteSetMs)) {
op.allowFailFastOnUnwritableChannel();
}
} finally {
ws.recycle();
}
}

try {
Expand Down

0 comments on commit cb70194

Please sign in to comment.