Skip to content

Commit c69a636

Browse files
committed
trace: track suspensions, check they match.
I added this debugging because the next test revealed a mismatch, so I wanted to see where it was happening. The comment in lightningd suggests it's possible, but I can't see any code which suspends in the lightningd io_loop, so I cannot see how this is triggered. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent f5f8725 commit c69a636

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

common/trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct span {
6767
struct span_tag *tags;
6868
char *name;
6969

70+
bool suspended;
7071
/* Indicate whether this is a remote span, i.e., it was
7172
inherited by some other process, which is in charge of
7273
emitting the span. This just means that we don't emit this
@@ -286,6 +287,7 @@ void trace_span_start(const char *name, const void *key)
286287
s->parent = current;
287288
s->tags = notleak(tal_arr(NULL, struct span_tag, 0));
288289
s->name = notleak(tal_strdup(NULL, name));
290+
s->suspended = false;
289291

290292
/* If this is a new root span we also need to associate a new
291293
* trace_id with it. */
@@ -369,6 +371,8 @@ void trace_span_suspend_(const void *key, const char *lbl)
369371
struct span *span = trace_span_find(numkey);
370372
TRACE_DBG("Suspending span %s (%zu)\n", current->name, current->key);
371373
assert(current == span);
374+
assert(!span->suspended);
375+
span->suspended = true;
372376
current = NULL;
373377
DTRACE_PROBE1(lightningd, span_suspend, span->id);
374378
}
@@ -402,6 +406,8 @@ void trace_span_resume_(const void *key, const char *lbl)
402406

403407
size_t numkey = trace_key(key);
404408
current = trace_span_find(numkey);
409+
assert(current->suspended);
410+
current->suspended = false;
405411
TRACE_DBG("Resuming span %s (%zu)\n", current->name, current->key);
406412
DTRACE_PROBE1(lightningd, span_resume, current->id);
407413
}

lightningd/lightningd.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,14 +1409,6 @@ int main(int argc, char *argv[])
14091409
/*~ Now handle sigchld, so we can clean up appropriately. */
14101410
sigchld_conn = notleak(io_new_conn(ld, sigchld_rfd, sigchld_rfd_in, ld));
14111411

1412-
/* This span was started before handing control to `io_loop`
1413-
* which suspends active spans in-between processing
1414-
* events. Depending on how the `io_loop` was interrupted, the
1415-
* current context span may have been suspended. We need to
1416-
* manually resume it for this case. Notice that resuming is
1417-
* idempotent, and doing so repeatedly is safe.
1418-
*/
1419-
trace_span_resume(argv);
14201412
trace_span_end(argv);
14211413

14221414
/*~ Mark ourselves live.

0 commit comments

Comments
 (0)