Skip to content

mz-debug: Fix HTTP dumping for multi-process clusters - #37816

Merged
SangJunBak merged 5 commits into
MaterializeInc:mainfrom
SangJunBak:jun/fix-http-multi-process-dumping
Jul 27, 2026
Merged

mz-debug: Fix HTTP dumping for multi-process clusters#37816
SangJunBak merged 5 commits into
MaterializeInc:mainfrom
SangJunBak:jun/fix-http-multi-process-dumping

Conversation

@SangJunBak

@SangJunBak SangJunBak commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

test/mz-debug: Assert emulator run produces all default output files

mz-debug: Scrape http resources per process instead of per service

Because multi-process replicas can have multiple pods per service, we account for that when dumping resources.

Motivation

Bug found here #37283 (review)

Description

Rather than just port forward the first pod of a service, finds the related process pods too

Verification

Created an e2e orchestratord test to assert

Nightly: https://buildkite.com/materialize/nightly/builds/17563

@SangJunBak

Copy link
Copy Markdown
Contributor Author

orchestratord test run https://buildkite.com/materialize/nightly/builds/17495

@SangJunBak
SangJunBak marked this pull request as ready for review July 23, 2026 02:07
@SangJunBak
SangJunBak requested a review from a team as a code owner July 23, 2026 02:07

@def- def- 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.

Thanks for fixing!

Comment thread ci/nightly/pipeline.template.yml Outdated
agents:
queue: hetzner-aarch64-16cpu-32gb

- id: orchestratord-mz-debug-scaled-replica

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.

This is maybe a bit too specific to add a full job in CI for.

@SangJunBak SangJunBak Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@def- I do feel like this test is valuable and something we don't already have in any pipeline: an e2e test of cpu/memory profiling in a cloud environment with multiple pods. It does feel weird to lump this into the orchestratord tests however. Would it make sense to port this as a cloudtest in cloudtest/test_mz_debug_tool.py?

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.

yes, cloudtest sounds good!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@SangJunBak
SangJunBak requested a review from sjwiesman July 23, 2026 12:58
@SangJunBak
SangJunBak marked this pull request as draft July 23, 2026 13:01
@SangJunBak
SangJunBak force-pushed the jun/fix-http-multi-process-dumping branch from 910e34e to f46e28b Compare July 23, 2026 13:18
Because multi-process replicas can have multiple pods per service, we account for that when dumping resources.
Creates a test that asserts each respective profile exists after an mz-debug run. Also tests for multi-process replicas
@SangJunBak
SangJunBak force-pushed the jun/fix-http-multi-process-dumping branch from f46e28b to bc1e0c7 Compare July 23, 2026 15:30
@SangJunBak
SangJunBak marked this pull request as ready for review July 23, 2026 16:16
@SangJunBak
SangJunBak requested a review from a team as a code owner July 23, 2026 16:16
@SangJunBak
SangJunBak requested review from alex-hunt-materialize and removed request for alex-hunt-materialize July 23, 2026 16:16
labels={
"app": "environmentd",
MZ_ORGANIZATION_NAME_LABEL: MZ_INSTANCE_NAME,
MZ_RESOURCE_ID_LABEL: "environmentd",

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.

The resource ID is a random string used for identifying which Materialize instance this object belongs to. It needs to match the resource ID used elsewhere.

This will not work if we ever instantiate multiple environments simultaneously.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done~

Comment thread test/cloudtest/test_mz_debug_tool.py Outdated
# `REPLICATION FACTOR 1` pins the cluster to exactly one replica, so the
# `scale=2` size yields exactly two clusterd pods behind one service.
mz.environmentd.sql(
f"CREATE CLUSTER {CLUSTER_NAME} SIZE 'scale={SCALE},workers=1', REPLICATION FACTOR 1"

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.

Can we also get a test with replication factor 2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done~

The `materialize.cloud/mz-resource-id` label ties a Kubernetes object to the
Materialize instance it belongs to, so every object of an instance carries the
same value and two instances never share one. Stamping the literal string
`environmentd` on the environmentd Service met neither requirement.

cloudtest now generates an organization name and a resource ID per
MaterializeApplication, in the format the operator assigns, and stamps both on
the environmentd Service and StatefulSet. mz-debug is handed the generated
organization name rather than a shared constant.
mz-debug has to walk two dimensions to reach every clusterd pod: the processes
of a replica, which share one service, and the replicas of a cluster, which each
get their own service. The profiling test only covered the first, so parametrize
it over a scale=2 replica and a replication factor 2 cluster.

Each case now asserts that a profile arrived for every expected pod by name,
rather than counting the profiles that carry a replica's id. Only profiles
written by the run under test count, because mz-debug names its output directory
after the current minute and runs seconds apart share one.
@SangJunBak
SangJunBak merged commit 8b438b6 into MaterializeInc:main Jul 27, 2026
38 checks passed
def- added a commit that referenced this pull request Jul 28, 2026
So we don't accidentally reuse an existing file from the same minute.
Follow-up to #37816
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.

3 participants