@@ -120,10 +120,10 @@ public boolean recover() throws LogException {
120
120
Lsn lastLsn = Lsn .LSN_INVALID ;
121
121
Loggable next ;
122
122
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 );
124
125
while ((next = reader .nextEntry ()) != null ) {
125
126
// LOG.debug(next.dump());
126
- progress .set (next .getLsn ().getOffset ());
127
127
if (next .getLogType () == LogEntryTypes .TXN_START ) {
128
128
// new transaction starts: add it to the transactions table
129
129
txnsStarted .put (next .getTransactionId (), next );
@@ -135,7 +135,10 @@ public boolean recover() throws LogException {
135
135
lastCheckpoint = (Checkpoint ) next ;
136
136
}
137
137
lastLsn = next .getLsn ();
138
+
139
+ scanProgressBar .set (next .getLsn ().getOffset ());
138
140
}
141
+ scanProgressBar .set (lastSize ); // 100%
139
142
} catch (final LogException e ) {
140
143
if (LOG .isDebugEnabled ()) {
141
144
LOG .debug ("Caught exception while reading log" , e );
@@ -250,10 +253,11 @@ private void doRecovery(final int txnCount, final Path last, final JournalReader
250
253
if (LOG .isInfoEnabled ())
251
254
{
252
255
LOG .info ("First pass: redoing {} transactions..." , txnCount );}
253
- final ProgressBar progress = new ProgressBar ("Redo " , FileUtils .sizeQuietly (last ));
254
256
Loggable next = null ;
255
257
int redoCnt = 0 ;
256
258
try {
259
+ final long lastSize = FileUtils .sizeQuietly (last );
260
+ final ProgressBar redoProgressBar = new ProgressBar ("Redo " , lastSize );
257
261
while ((next = reader .nextEntry ()) != null ) {
258
262
SanityCheck .ASSERT (next .getLogType () != LogEntryTypes .CHECKPOINT ,
259
263
"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
271
275
// LOG.debug("Redo: " + next.dump());
272
276
// redo the log entry
273
277
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
+ }
277
283
}
284
+ redoProgressBar .set (lastSize ); // 100% done
278
285
} catch (final Exception e ) {
279
286
LOG .error ("Exception caught while redoing transactions. Aborting recovery to avoid possible damage. " +
280
287
"Before starting again, make sure to run a check via the emergency export tool." , e );
0 commit comments