fix(log): suppress spurious error logs when solidity node exits#6801
fix(log): suppress spurious error logs when solidity node exits#6801317787106 wants to merge 1 commit into
Conversation
73567d3 to
14b4d46
Compare
| try { | ||
| long time = System.currentTimeMillis(); | ||
| Block block = databaseGrpcClient.getBlock(blockNum); | ||
| if (block == null) { |
There was a problem hiding this comment.
Looking at DatabaseGrpcClient.getBlock(), it delegates to databaseBlockingStub.getBlockByNum(...) — a gRPC blocking stub. Per gRPC semantics, blocking stubs don't return null: success returns a response message (the default instance is still a non-null object), and channel teardown/cancellation/deadline expiry surfaces as StatusRuntimeException (CANCELLED / UNAVAILABLE / DEADLINE_EXCEEDED), not null.
A few questions:
- Have we observed this null path being hit in production? If so, what's the server-side implementation that produces it?
- If this is purely defensive (against mocks or future stub changes), could we add an inline comment? Future readers will spend time looking for "when does this return null."
There was a problem hiding this comment.
You're right, it is defensive. Per gRPC semantics, a blocking stub call never returns null — on channel teardown it throws StatusRuntimeException (e.g. CANCELLED), which is already caught by the outer catch (Exception e) block and logged as INFO via the !flag guard. Removed the unreachable null check.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
14b4d46 to
d1ecbc1
Compare
What does this PR do?
ERROR ... reason: nulllogs when the solidity node shuts down.Root cause
close()callsgetBlockExecutor.shutdownNow()while theget-blockthread may be blocked inblockQueue.put(). That throwsInterruptedException, whosegetMessage()returnsnull. The originalcatch (Exception e)logged it as an ERROR withreason: null.The original
sleep()had the same issue: it caughtExceptioninstead ofInterruptedException, logged a null message, and never restored the interrupt flag.Changes
getBlock()catch (InterruptedException e)— restore interrupt flag, log INFO, returngetBlock()!flagguard incatch (Exception e)— log INFO instead of ERROR on shutdowngetBlockByNum()getLastSolidityBlockNum()!flagguard — same pattern asgetBlock()sleep()InterruptedExceptionspecifically and restore interrupt status