Skip to content

Commit

Permalink
Re #856: using out of space code on exit from the tasks for importing…
Browse files Browse the repository at this point in the history
… blocks

 - also handling the interrupted exceptions in TaskFastImportBlocks
  • Loading branch information
AlexandraRoatis committed Mar 21, 2019
1 parent cf04d21 commit a8e59a1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
17 changes: 15 additions & 2 deletions modAionImpl/src/org/aion/zero/impl/sync/TaskFastImportBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.aion.mcf.core.FastImportResult;
import org.aion.types.ByteArrayWrapper;
import org.aion.zero.impl.AionBlockchainImpl;
import org.aion.zero.impl.SystemExitCodes;
import org.aion.zero.impl.types.AionBlock;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
Expand Down Expand Up @@ -46,6 +47,12 @@ public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
if (!fastSyncMgr.isComplete()) {
log.error(
"Fast import blocks thread interrupted without shutdown request.",
e);
}
return;
}
} else {
if (requiredLevel == 0 || requiredHash == null) {
Expand All @@ -58,6 +65,12 @@ public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
if (!fastSyncMgr.isComplete()) {
log.error(
"Fast import blocks thread interrupted without shutdown request.",
e);
}
return;
}
}
} else {
Expand Down Expand Up @@ -122,8 +135,8 @@ public void run() {

if (e.getMessage() != null
&& e.getMessage().contains("No space left on device")) {
log.error("Shutdown due to lack of disk space.");
System.exit(0);
log.error("Shutdown due to lack of disk space.", e);
System.exit(SystemExitCodes.OUT_OF_DISK_SPACE);
}
break;
}
Expand Down
16 changes: 9 additions & 7 deletions modAionImpl/src/org/aion/zero/impl/sync/TaskImportBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import org.aion.types.ByteArrayWrapper;
import org.aion.mcf.core.ImportResult;
import org.aion.p2p.P2pConstant;
import org.aion.types.ByteArrayWrapper;
import org.aion.zero.impl.AionBlockchainImpl;
import org.aion.zero.impl.SystemExitCodes;
import org.aion.zero.impl.db.AionBlockStore;
import org.aion.zero.impl.sync.PeerState.Mode;
import org.aion.zero.impl.types.AionBlock;
Expand Down Expand Up @@ -267,8 +268,8 @@ private PeerState processBatch(PeerState givenState, List<AionBlock> batch, Stri
log.error("<import-block throw> ", e);

if (e.getMessage() != null && e.getMessage().contains("No space left on device")) {
log.error("Shutdown due to lack of disk space.");
System.exit(0);
log.error("Shutdown due to lack of disk space.", e);
System.exit(SystemExitCodes.OUT_OF_DISK_SPACE);
}
break;
}
Expand All @@ -280,7 +281,8 @@ private PeerState processBatch(PeerState givenState, List<AionBlock> batch, Stri

// if any block results in NO_PARENT, all subsequent blocks will too
if (importResult == ImportResult.NO_PARENT) {
executors.submit(new TaskStorePendingBlocks(chain, batch, displayId, syncStats, log));
executors.submit(
new TaskStorePendingBlocks(chain, batch, displayId, syncStats, log));

if (log.isDebugEnabled()) {
log.debug(
Expand Down Expand Up @@ -581,7 +583,7 @@ private ImportResult importBlock(AionBlock b, String displayId, PeerState state)
log.info("Compacting state database due to slow IO time.");
}
t1 = System.currentTimeMillis();
//this.chain.compactState();
// this.chain.compactState();
t2 = System.currentTimeMillis();
if (log.isInfoEnabled()) {
log.info("Compacting state completed in {} ms.", t2 - t1);
Expand Down Expand Up @@ -700,8 +702,8 @@ private int importFromStorage(PeerState state, long first, long last) {
log.error("<import-block throw> ", e);
if (e.getMessage() != null
&& e.getMessage().contains("No space left on device")) {
log.error("Shutdown due to lack of disk space.");
System.exit(0);
log.error("Shutdown due to lack of disk space.", e);
System.exit(SystemExitCodes.OUT_OF_DISK_SPACE);
}
}
}
Expand Down

0 comments on commit a8e59a1

Please sign in to comment.