Repository navigation
Conversation
When a tuple tree times out, the spout executor calls ISpout.fail() with the message id only, so the spout cannot tell a timeout from an explicit fail. With topology.message.timeout.report set to timeout-events (the default is disabled), the worker logs the timeouts of its spouts: timeout root=00000000075bcd15 task=7 component=url-spout id="https://example.org/a" At INFO, the first word names the line type. root is the id of the tuple tree as 16 hexadecimal digits. task and component name the spout task that emitted the tree. id is the message id when it is a String, and it is always the last field; any other type is written id=<not supported>, and the reporter calls no method of it. An explicit fail that reaches the spout before the timeout writes nothing. The spout executor hands the event to MessageTimeoutReporter before it calls ISpout.fail(). All spouts of a worker share one queue of 1024 events, and a daemon thread of the reporter writes them at INFO, so a blocked log does not hold the spout. An event that finds the queue full is counted and dropped before it is formatted. Each cycle of the thread writes up to 1024 queued events, then the counters that changed since the last summary whose logging call returned, and waits one second: summary events_dropped=3 Backslash, control, format, line separator, paragraph separator and unpaired surrogate characters in a message id become escapes such as \u{a}. An id whose escaped form exceeds 1024 UTF-16 units is cut and marked with truncated=true originalLength=N, which counts toward the same 1024 units. A component id is cut at 64 units, with a space written as an escape too. A log call that throws is counted as write_failed and the report goes on. A RuntimeException that escapes a cycle of the reporter's thread turns the report off until the worker restarts; the reporter then makes one attempt to log this at ERROR. An Error reaches the uncaught exception handler. With the report disabled, the worker creates no reporter and the expiry path tests one field. docs/Message-timeout-report.md describes the lines, their limits and how to read them.
| * {@code org.apache.storm.daemon.worker.MessageTimeoutReporter} at INFO. With {@code disabled}, the default, | ||
| * nothing is reported. | ||
| */ | ||
| @IsString(acceptedValues = {"disabled", "timeout-events"}) |
There was a problem hiding this comment.
A string so we can add another mode later without a second key. Happy to make it a boolean if you prefer.
There was a problem hiding this comment.
I have a prototype that also logs deliveries a bvolt hels past the timeout, proposing later :)
|
|
||
| /** Fixed width, so that a whole token is never the prefix of another root's token. */ | ||
| static String rootToken(long rootId) { | ||
| return "root=" + HexFormat.of().toHexDigits(rootId); |
There was a problem hiding this comment.
I picked hex to get a fixed width and no sign. topology.debug prints the root in decimal though, so happy to switch if you prefer that.
| /** Returns the {@code id} field of an event, after the truncation fields when the id is cut. */ | ||
| static String idField(Object messageId) { | ||
| if (!(messageId instanceof String id)) { | ||
| return "id=<not supported>"; |
There was a problem hiding this comment.
This runs on the spout executor's thread, so I didn't want to call toString() on a class I know nothing about. It means Kafka spout ids show up as <not supported>, so I'm open to ideas.
| @Override | ||
| public void expire(Long key, TupleInfo tupleInfo) { | ||
| if (timeoutReporter != null) { | ||
| timeoutReporter.timedOut(key, tupleInfo.getTaskId(), componentId, tupleInfo.getMessageId()); |
There was a problem hiding this comment.
Another option would be a reason on SpoutFailInfo for task hooks. Would you prefer that?
What is the purpose of the change
When Storm calls
fail()on a spout, the spout receives the message id and nothing else. A tuple tree that timed out and a tuple that a bolt failed reach the spout through the samefail()call. In a StormCrawler crawl the message id can be the URL, sofail()cannot say whether that URL timed out or a bolt failed it. STORM-154 (#3996) asked for this distinction. Its JIRA entry was opened in 2013.Today
topology.debug: truelogs the reason at INFO, along with a line for every spout ack and for every tuple a bolt executes. A tracer set withtopology.tracing.traceralso receivesTIMEOUTorFAIL, for tuple trees that carry a trace context.This PR adds a log line for a spout timeout, off by default:
rootis the id of the tuple tree that timed out. A replay of the same URL is a new emit and gets a new random id.taskandcomponentname the spout task that emitted the tree. They identify only the origin of the tree.idis the message id when it is aString, and it is always the last field. Any other type is writtenid=<not supported>.Turning it on. Set it in the topology configuration. The default is
disabled.Finding the line for a URL. Search the log of the spout's worker for part of the id, or for the whole token
root=00000000075bcd15. Other Storm logs print root ids in decimal.An explicit fail. When a bolt fails the tuple and the fail reaches the spout before the timeout, the reporter writes no line for that root.
How it works.
fail()while the reporter is blocked writing a timeout line.What a missing line means. A timeout can leave no line for its root, for example when the queue was full or the reporter's logger is set to WARN or higher. That level also hides the summary lines. The docs list the other cases.
The report works with tuple tracing disabled.
docs/Message-timeout-report.mdin this diff has the rest: the escapes, the truncation of long ids, the counters.TL;DR. An opt-in log line that says "this tuple tree timed out" and carries the message id when it is a
String. The configuration key and the line format become public on release, so I'd welcome feedback on both now.How was the change tested
MessageTimeoutReporterTestcover the line format, escaping and truncation of ids, a full queue, summaries, log write exceptions and reporter thread failures.SpoutExecutorTestchecks that the executor still callsspout.fail()on timeout after an exception stops the reporter thread.TestConfigValidatechecks the two accepted values and thedisableddefault.MessageTimeoutReportTestruns three cases on aLocalCluster. In the first, a spout timeout produces a line with the root, spout task and URL, and an explicit fail that reaches the spout before the timeout produces no timeout line for that root. In the second, with the default settings, the worker starts no reporter thread and writes no report. In the third, the reporter is blocked writing the first timeout line while the spout receivesfail()for a second URL.storm-client,storm-serverandstorm-opentelemetrysuites finished with zero failures or errors. Four client tests and one server test were skipped.cc @GGraziadei @rzo1 @reiabreu