Skip to content

obs: permanent structured emit-decision debug logging#37

Merged
eilandert merged 1 commit into
masterfrom
obs/zstd-emit-debug-logging
May 18, 2026
Merged

obs: permanent structured emit-decision debug logging#37
eilandert merged 1 commit into
masterfrom
obs/zstd-emit-debug-logging

Conversation

@eilandert

Copy link
Copy Markdown
Owner

What

Adds two gated ngx_log_debug calls at the output emit-decision point in ngx_http_zstd_filter_compress:

zstd emit?: outsz:N rc0:N last:N ctx_last:N ctx_flush:N action:N
zstd emit: suppressed empty non-terminal buffer

NGX_DEBUG-gated (the ngx_log_debug* macros expand to nothing in release builds) → zero runtime cost when off, visible with error_log ... debug. No behaviour change — it only observes the existing guard.

Why

This module has a recurring truncation / zero-size-buffer / terminal-frame bug class (a209f96, 2af5889, PR#23/#49, the in-progress bug B). Every prior diagnosis required temporarily patching debug lines in and rebuilding — repeatedly, this session included. This makes the single most diagnostic probe permanent: exactly what state the emit guard saw and why it suppressed/forwarded a buffer. During bug-B investigation it immediately exposed the forced-flush-under-proxy_buffering off mechanism with no patch/rebuild loop.

Scope

Observability only. This is not the bug-B fix (that is unsolved and tracked separately in BUG-B-PLAN.md / BUG-B-RUNBOOK.md). Shipping this independently so the diagnostic exists in tree for the ongoing investigation and future regressions.

Verification

  • Builds clean under the project -Werror -Wall flags (nginx 1.31.0).
  • No logic/guard change (diff is purely the two ngx_log_debug blocks).

Add gated ngx_log_debug at the output emit-decision point in
ngx_http_zstd_filter_compress:

  zstd emit?: outsz:N rc0:N last:N ctx_last:N ctx_flush:N action:N
  zstd emit: suppressed empty non-terminal buffer

NGX_DEBUG-gated (the ngx_log_debug* macros compile to nothing in
release builds), so zero runtime cost when off; visible with
`error_log ... debug`. Behaviour is unchanged — this only observes the
existing guard, it does not alter it.

Rationale: this module has a recurring truncation / zero-size-buffer /
terminal-frame bug class (a209f96, 2af5889, PR#23/#49, the 2026-05
bug B). Every prior diagnosis required temporarily patching in debug
lines and rebuilding, repeatedly. This makes the single most diagnostic
probe permanent: the exact state the emit guard saw. Verified during
bug-B work — it immediately exposed the forced-flush mechanism without
a patch/rebuild loop.

Builds clean under the project -Werror flags (nginx 1.31.0).
@eilandert eilandert merged commit 53b9fa4 into master May 18, 2026
12 checks passed
@eilandert eilandert deleted the obs/zstd-emit-debug-logging branch May 18, 2026 19:53
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