Skip to content

[NEW] Log EXEC in commandlog to surface slow transactions with fast inner commands #4261

Closed

Description

@michellee-10

The problem/use-case that the feature addresses

EXEC has been excluded from the slow log since 2013 (redis/redis@08d200baeb, fixing redis/redis#759) on the grounds that logging it was "perfectly useless." The slow inner commands were already logged individually. That check became CMD_SKIP_SLOWLOG (7d21754), then SKIP_COMMANDLOG (#1294 / 3f21705). src/commands/exec.json is the flag's only remaining user.

The problem: that reasoning assumes at least one inner command will cross the threshold. It doesn't hold for transactions of many individually-fast commands. None of them trips commandlog-execution-slower-than (default 10ms), and nothing is logged even though the event loop was blocked for the sum.

This makes diagnosis harder than it needs to be. A client wrapping hundreds of small commands in MULTI/EXEC can stall the server for hundreds of ms with nothing in the commandlog.

Reproduction against unstable, threshold at default 10ms:

# 30 commands, each ~5ms (below threshold), ~150ms total
$ { echo MULTI; for i in $(seq 1 30); do echo "DEBUG SLEEP 0.005"; done; echo EXEC; } | valkey-cli

$ valkey-cli commandlog get -1 slow
(empty array)

$ valkey-cli info commandstats | grep -E 'cmdstat_(exec|debug|multi)'
cmdstat_debug:calls=30,usec=182643,usec_per_call=6088.10,rejected_calls=0,failed_calls=0
cmdstat_multi:calls=1,usec=1,usec_per_call=1.00,rejected_calls=0,failed_calls=0
cmdstat_exec:calls=1,usec=182686,usec_per_call=182686.00,rejected_calls=0,failed_calls=0

Commandstats shows EXEC took 182,686µs, 18x the 10ms threshold, yet the commandlog is empty.

Description of the feature

Remove SKIP_COMMANDLOG from src/commands/exec.json. EXEC's measured duration already includes the execution time of all queued commands (each inner call() accumulates into c->duration), so no other changes are needed. The flag is the only thing suppressing the entry.

After the change: inner commands still log individually when they're slow, and EXEC additionally logs the transaction total when it exceeds the threshold. On the duplicate-entry concern from redis#759: EXEC's entry is often the only record (when no inner command is individually slow), and when inner commands do log, EXEC adds the transaction total on top.

The existing tests at tests/unit/slowlog.tcl:175 and tests/unit/commandlog.tcl:265 assert EXEC is not logged, those would be updated to expect it. The current docs don't mention the EXEC exclusion, so no documented contract breaks.

Alternatives you've considered

  1. Lower commandlog-execution-slower-than. - Creates more noise for the common case, and still doesn't fix the problem unless the threshold is set unreasonably low.
  2. Gate it behind a new config flag - Backward compatible, but nobody will have it enabled during the incident where they needed it — unnecessary complexity.

Additional information

Related discussion in #1424, where logging EXEC in the slowlog was suggested but never landed. The concern raised was that EXEC's duration is misleading since it's just the sum of its inner commands. However, that sum is the contiguous time the event loop was blocked, which is helpful when an operator is investigating latency issues.

Activity

  1. added
    enhancement
    on Jul 23, 2026
  2. added a commit that references this issue on Jul 24, 2026
    46feafc
  3. added
    needs-review
    on Aug 5, 2026
  4. JimB123 commented on Aug 5, 2026

    @JimB123
    Member

    Thanks for raising this issue. Indeed, we shouldn't be excluding this case from COMMANDLOG.

    The original argument that logging a slow EXEC was "perfectly useless" relied on the assumption that a slow command within the exec was causing the issue - and that would be logged. The EXEC logging would then be redundant logging which provides less information than the actual slow command. Given the limited size of the SLOWLOG, it is reasonably assumed that the intent of eliminating EXEC would be to eliminate clutter in the SLOWLOG. This concern still exists.

    It is also noted that the current behavior is inconsistent with LUA scripts - which have the identical issue. But in the case of LUA, we log the script in addition to the internal slow command.

    A more perfect solution might be to skip logging of the EXEC (or LUA) IFF one of the EXEC's (or LUA's) inner commands has already been logged.

    Since this is a (slight) behavioral change, marking this for maintainer review. I recommend adding to the agenda for one of the Monday TSC meetings.

  5. added
    major-decision-pending
    and removed
    major-decision-pending
    on Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions