Skip to content

Commit e23d7f8

Browse files
committed
[bugfix] Make sure Journal Recovery progress bars reach 100%
1 parent 72c8604 commit e23d7f8

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

exist-core/src/main/java/org/exist/storage/recovery/RecoveryManager.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ public boolean recover() throws LogException {
120120
Lsn lastLsn = Lsn.LSN_INVALID;
121121
Loggable next;
122122
try {
123-
final ProgressBar progress = new ProgressBar("Scanning journal ", FileUtils.sizeQuietly(last));
123+
final long lastSize = FileUtils.sizeQuietly(last);
124+
final ProgressBar scanProgressBar = new ProgressBar("Scanning journal ", lastSize);
124125
while ((next = reader.nextEntry()) != null) {
125126
// LOG.debug(next.dump());
126-
progress.set(next.getLsn().getOffset());
127127
if (next.getLogType() == LogEntryTypes.TXN_START) {
128128
// new transaction starts: add it to the transactions table
129129
txnsStarted.put(next.getTransactionId(), next);
@@ -135,7 +135,10 @@ public boolean recover() throws LogException {
135135
lastCheckpoint = (Checkpoint) next;
136136
}
137137
lastLsn = next.getLsn();
138+
139+
scanProgressBar.set(next.getLsn().getOffset());
138140
}
141+
scanProgressBar.set(lastSize); // 100%
139142
} catch (final LogException e) {
140143
if (LOG.isDebugEnabled()) {
141144
LOG.debug("Caught exception while reading log", e);
@@ -250,10 +253,11 @@ private void doRecovery(final int txnCount, final Path last, final JournalReader
250253
if (LOG.isInfoEnabled())
251254
{
252255
LOG.info("First pass: redoing {} transactions...", txnCount);}
253-
final ProgressBar progress = new ProgressBar("Redo ", FileUtils.sizeQuietly(last));
254256
Loggable next = null;
255257
int redoCnt = 0;
256258
try {
259+
final long lastSize = FileUtils.sizeQuietly(last);
260+
final ProgressBar redoProgressBar = new ProgressBar("Redo ", lastSize);
257261
while ((next = reader.nextEntry()) != null) {
258262
SanityCheck.ASSERT(next.getLogType() != LogEntryTypes.CHECKPOINT,
259263
"Found a checkpoint during recovery run! This should not ever happen.");
@@ -271,10 +275,13 @@ private void doRecovery(final int txnCount, final Path last, final JournalReader
271275
// LOG.debug("Redo: " + next.dump());
272276
// redo the log entry
273277
next.redo();
274-
progress.set(next.getLsn().getOffset());
275-
if (next.getLsn().equals(lastLsn))
276-
{break;} // last readable entry reached. Stop here.
278+
redoProgressBar.set(next.getLsn().getOffset());
279+
if (next.getLsn().equals(lastLsn)) {
280+
// last readable entry reached. Stop here.
281+
break;
282+
}
277283
}
284+
redoProgressBar.set(lastSize); // 100% done
278285
} catch (final Exception e) {
279286
LOG.error("Exception caught while redoing transactions. Aborting recovery to avoid possible damage. " +
280287
"Before starting again, make sure to run a check via the emergency export tool.", e);

0 commit comments

Comments
 (0)