Skip to content

fix(logtail): reduce consumer backlog pressure (#24323) - #24330

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix-logtail-consumer-backlog-main
May 11, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:fix-logtail-consumer-backlog-main

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24322

What this PR does / why we need it:

Fixes the CN logtail consumer backlog risk found in nightly sysbench write-heavy regressions.

The bad run had logtail.consumer.slow.* in the update_pk_1000 window, with signal-chan-len around 7373~7738 on one CN consumer routine. The good control run using the same MO image did not have these slow logs in the same case window. No sysbench reconnect/retry storm, workspace quota shortage, or UPDATE table-lock upgrade was found.

This PR reduces internal backpressure without changing table assignment or increasing consumer routine count:

  • coalesces update-response timestamp commands for routines that already have table logtail commands,
  • advances the routine applied timestamp only after that routine consumes the last table logtail for the response,
  • keeps timestamp-only commands for routines that do not receive table logtails, preserving global min applied timestamp semantics,
  • makes timestamp waiter commit-ts notifications non-blocking and coalesced to the latest timestamp,
  • adds tests for non-blocking timestamp notifications, bounded notification draining, and logtail timestamp advancement ordering.

Fixes the CN logtail consumer backlog risk found in nightly sysbench write-heavy regressions.

The bad run had `logtail.consumer.slow.*` in the `update_pk_1000` window, with `signal-chan-len` around 7373~7738 on one CN consumer routine. The good control run using the same MO image did not have these slow logs in the same case window. No sysbench reconnect/retry storm, workspace quota shortage, or UPDATE table-lock upgrade was found.

This PR reduces internal backpressure without changing table assignment or increasing consumer routine count:

- coalesces update-response timestamp commands for routines that already have table logtail commands,
- advances the routine applied timestamp only after that routine consumes the last table logtail for the response,
- keeps timestamp-only commands for routines that do not receive table logtails, preserving global min applied timestamp semantics,
- makes timestamp waiter commit-ts notifications non-blocking and coalesced to the latest timestamp,
- adds tests for non-blocking timestamp notifications, bounded notification draining, and logtail timestamp advancement ordering.

Approved by: @XuPeng-SH
Copilot AI review requested due to automatic review settings May 11, 2026 03:07
@qodo-code-review

Copy link
Copy Markdown
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR mitigates CN logtail consumer backlog/backpressure in the disttae logtail push path by coalescing timestamp-only work and making timestamp waiter notifications non-blocking, aiming to reduce queue growth during write-heavy workloads (issue #24322).

Changes:

  • Coalesce per-routine applied-timestamp updates into the last table-logtail command for routines that already receive table logtails, avoiding extra timestamp-only commands.
  • Advance routine applied timestamps only after that routine consumes the last logtail for a response, while preserving global min-applied semantics for routines with no logtails.
  • Make TimestampWaiter.NotifyLatestCommitTS non-blocking and coalesce notifications to the latest timestamp; add targeted tests for these behaviors.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/vm/engine/disttae/logtail_consumer.go Coalesces timestamp advancement with the final logtail command per routine; reduces timestamp-only command fanout.
pkg/vm/engine/disttae/logtail_consumer_test.go Adds tests validating timestamp-command coalescing and “advance-after-last-logtail” ordering.
pkg/txn/client/timestamp_waiter.go Switches to non-blocking, coalesced wakeups using a struct notification channel plus an atomic “latest notified” timestamp.
pkg/txn/client/timestamp_waiter_test.go Adds tests for non-blocking behavior under full channel, redundant wakeup skipping, and bounded draining.

@gouhongshen gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Code Review — LGTM

This is a clean cherry-pick of #24323 (squashed into a single commit) backported to main. The code changes are identical — verified via diff comparison.

This PR was already reviewed in depth as part of #24323 with the 七人陪审团 multi-agent review process. Summary of that review:

  • 🔴 Must Fix: 0
  • 🟡 Should Fix: 3 (pool reset style, dual-loop duplication, concurrent test coverage)
  • 🟢 Nit: 4
  • Design: Sound — lock-free CAS coalescing + two-phase dispatch correctly eliminates per-response redundant timestamp commands
  • Correctness: Monotonic advancement guard in handleEvent ensures no timestamp regression even under ABA race

The squashed single-commit form is cleaner than the original 3-commit history. No additional concerns for the backport.

Approved ✅

@mergify mergify Bot added the queued label May 11, 2026
@mergify

mergify Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-05-11 06:09 UTC · Rule: main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-05-11 07:08 UTC · at 21b687cdbed044cac7b53243dd7889a000524306 · squash

This pull request spent 59 minutes 15 seconds in the queue, including 58 minutes 56 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage

@mergify
mergify Bot merged commit be83141 into matrixorigin:main May 11, 2026
23 of 24 checks passed
@mergify mergify Bot removed the queued label May 11, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…atrixorigin#24330)

Fixes the CN logtail consumer backlog risk found in nightly sysbench write-heavy regressions.

The bad run had `logtail.consumer.slow.*` in the `update_pk_1000` window, with `signal-chan-len` around 7373~7738 on one CN consumer routine. The good control run using the same MO image did not have these slow logs in the same case window. No sysbench reconnect/retry storm, workspace quota shortage, or UPDATE table-lock upgrade was found.

This PR reduces internal backpressure without changing table assignment or increasing consumer routine count:

- coalesces update-response timestamp commands for routines that already have table logtail commands,
- advances the routine applied timestamp only after that routine consumes the last table logtail for the response,
- keeps timestamp-only commands for routines that do not receive table logtails, preserving global min applied timestamp semantics,
- makes timestamp waiter commit-ts notifications non-blocking and coalesced to the latest timestamp,
- adds tests for non-blocking timestamp notifications, bounded notification draining, and logtail timestamp advancement ordering.

Approved by: @gouhongshen, @XuPeng-SH, @iamlinjunhong
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…atrixorigin#24330)

Fixes the CN logtail consumer backlog risk found in nightly sysbench write-heavy regressions.

The bad run had `logtail.consumer.slow.*` in the `update_pk_1000` window, with `signal-chan-len` around 7373~7738 on one CN consumer routine. The good control run using the same MO image did not have these slow logs in the same case window. No sysbench reconnect/retry storm, workspace quota shortage, or UPDATE table-lock upgrade was found.

This PR reduces internal backpressure without changing table assignment or increasing consumer routine count:

- coalesces update-response timestamp commands for routines that already have table logtail commands,
- advances the routine applied timestamp only after that routine consumes the last table logtail for the response,
- keeps timestamp-only commands for routines that do not receive table logtails, preserving global min applied timestamp semantics,
- makes timestamp waiter commit-ts notifications non-blocking and coalesced to the latest timestamp,
- adds tests for non-blocking timestamp notifications, bounded notification draining, and logtail timestamp advancement ordering.

Approved by: @gouhongshen, @XuPeng-SH, @iamlinjunhong
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…atrixorigin#24330)

Fixes the CN logtail consumer backlog risk found in nightly sysbench write-heavy regressions.

The bad run had `logtail.consumer.slow.*` in the `update_pk_1000` window, with `signal-chan-len` around 7373~7738 on one CN consumer routine. The good control run using the same MO image did not have these slow logs in the same case window. No sysbench reconnect/retry storm, workspace quota shortage, or UPDATE table-lock upgrade was found.

This PR reduces internal backpressure without changing table assignment or increasing consumer routine count:

- coalesces update-response timestamp commands for routines that already have table logtail commands,
- advances the routine applied timestamp only after that routine consumes the last table logtail for the response,
- keeps timestamp-only commands for routines that do not receive table logtails, preserving global min applied timestamp semantics,
- makes timestamp waiter commit-ts notifications non-blocking and coalesced to the latest timestamp,
- adds tests for non-blocking timestamp notifications, bounded notification draining, and logtail timestamp advancement ordering.

Approved by: @gouhongshen, @XuPeng-SH, @iamlinjunhong

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants