Skip to content

logger: Wait for the writer thread before returning from init - #231

Open
jasonsopko wants to merge 1 commit into
OCEAN-xyz:masterfrom
jasonsopko:logger-wait-init
Open

logger: Wait for the writer thread before returning from init#231
jasonsopko wants to merge 1 commit into
OCEAN-xyz:masterfrom
jasonsopko:logger-wait-init

Conversation

@jasonsopko

Copy link
Copy Markdown

What

datum_logger_init now 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_init and datum_api_init, goes to the console if console logging is on and nowhere if it is off. With log_to_console: false and a log file, the DATUM 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-POOLED appears 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. --test passes. 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant