logger: Wait for the writer thread before returning from init - #231
Open
jasonsopko wants to merge 1 commit into
Open
logger: Wait for the writer thread before returning from init#231jasonsopko wants to merge 1 commit into
jasonsopko wants to merge 1 commit into
Conversation
datum_logger_init started the thread and returned at once. Anything logged in the next millisecond, which includes datum_protocol_init and datum_api_init, went to the console if console logging was on and nowhere if it was off, so a file-only configuration never saw the "DATUM pool host is blank. NON-POOLED MINING!" warning. Seen on a testnet4 gateway today. Wait up to two seconds for the thread to open the file and set datum_logger_initialized. The thread panics on its own if the file cannot be opened, so the wait cannot hang startup. Same config both ways (console off, file on, INFO), no node attached: the warning reaches the file 0 times before and once after. --test passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
datum_logger_initnow waits, up to two seconds, for the writer thread to open the log file before returning.Why
It starts the thread and returns at once. Anything logged in the next millisecond, which includes
datum_protocol_initanddatum_api_init, goes to the console if console logging is on and nowhere if it is off. Withlog_to_console: falseand a log file, theDATUM pool host is blank. NON-POOLED MINING!warning never reaches the file. Seen on a testnet4 gateway today: the file opens with the API thread's first line and the startup warnings are gone.How I tested
Same config both ways (console off, file on, INFO level), a gateway with no node attached, five seconds. Before:
NON-POOLEDappears 0 times in the file. After: once. Then on a testnet4 gateway with its real file-only config: the warning and the API thread's startup lines are in the file, where the previous build's run of the same config had only the template thread's lines.--testpasses. The wait is bounded and the thread panics on its own if the file cannot be opened, so startup cannot hang on it.Risk and rollback
Startup is a few milliseconds slower. Revert the commit.