You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Marton Greber (Code Review)" <ge...@cloudera.org> on 2026/09/21 13:29:05 UTC

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Marton Greber has uploaded this change for review. ( http://gerrit.cloudera.org:8080/24905


Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................

KUDU-3806: add deadline-bounded WaitAndCollect()

Add Subprocess::WaitAndCollect(), which concurrently drains the child's
piped stdout and stderr while waiting for it to exit, up to a deadline.
Draining both pipes together means a large write on one cannot deadlock
against a full buffer on the other; if the deadline passes first the
child is killed (SIGKILL), '*timed_out' is set, and whatever output was
collected so far is still returned.

To support this, ReadFdsFully() gains a deadline: a one-shot libev timer
(DeadlineHelper) breaks the drain loop when it fires, and each fd watcher
now decrements a shared open-count so the loop ends deterministically at
EOF even with the timer armed. An uninitialized deadline preserves the
historical "drain to EOF" behavior, which is what Subprocess::Call()
continues to pass.

This is groundwork for running each MCP tools/call in a bounded child
'kudu' process.

Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
M src/kudu/util/subprocess-test.cc
M src/kudu/util/subprocess.cc
M src/kudu/util/subprocess.h
3 files changed, 247 insertions(+), 21 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/05/24905/1
-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 1
Gerrit-Owner: Marton Greber <gr...@gmail.com>

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 3:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24905/3/src/kudu/util/subprocess-test.cc
File src/kudu/util/subprocess-test.cc:

http://gerrit.cloudera.org:8080/#/c/24905/3/src/kudu/util/subprocess-test.cc@265
PS3, Line 265:   ASSERT_OK(p.WaitAndCollect(MonoDelta::FromSeconds(1),
             :                              &out, &err, &timed_out, &wait_status));
> Could this be flaky? The 1s deadline races fork plus exec of bash plus the 
Honestly I wasn't sure. I've submitted: ./bin/subprocess-test --stress_cpu_threads=32 (in debug build) on dist-test, 100% went green:
http://dist-test.cloudera.org/job?job_id=root.1790253280.18230

Let me know if this is satisfactory or if i should investigate further.



-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Thu, 24 Sep 2026 12:42:54 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 4: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3037/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 4
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Thu, 24 Sep 2026 13:50:40 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 2:

Build Aborted 

http://jenkins.kudu.apache.org/job/pre_commit/3013/ : ABORTED


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 2
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 11:03:41 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Gabriella Lotz (Code Review)" <ge...@cloudera.org>.
Gabriella Lotz has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 3:

(1 comment)

Thanks for working on this! 1 question, otherwise LGTM.

http://gerrit.cloudera.org:8080/#/c/24905/3/src/kudu/util/subprocess-test.cc
File src/kudu/util/subprocess-test.cc:

http://gerrit.cloudera.org:8080/#/c/24905/3/src/kudu/util/subprocess-test.cc@265
PS3, Line 265:   ASSERT_OK(p.WaitAndCollect(MonoDelta::FromSeconds(1),
             :                              &out, &err, &timed_out, &wait_status));
Could this be flaky? The 1s deadline races fork plus exec of bash plus the two echos, and if setup loses that race both ASSERT_EQs at 269-270 see empty strings.



-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 12:39:33 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 3:

(9 comments)

Thank you for the comments Alexey!

http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess-test.cc
File src/kudu/util/subprocess-test.cc:

http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess-test.cc@173
PS1, Line 173:   ASSERT_FALSE(timed_out);
             :   ASSERT_EQ("out\n", out);
             :   ASSERT_EQ("err\n", err);
             :   ASSERT_TRUE(WIFEXITED(wait_status));
             :   ASSERT_EQ(0, WEXITSTATUS(wait_status));
> Here and below: what's the reason behind this mix of EXPECT_xxx and ASSERT_
Changed to use ASSERTs only.


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess-test.cc@241
PS1, Line 241: }
> One more test scenario that I'd think of adding is this:
Yepp makes sense, added 2 new tests.


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess-test.cc@242
PS1, Line 242: 
> In the context of covering edge cases, does it make sense to add a test sce
Added TestWaitAndCollectExpiredDeadline let me know what you think.


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.h
File src/kudu/util/subprocess.h:

http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.h@148
PS1, Line 148: MonoDelt
> In all the call sites of WaitAndCollect, it's necessary to first find curre
Makes sense changed to MonoDelta.


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc
File src/kudu/util/subprocess.cc:

http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@268
PS1, Line 268: 
> Does it make sense to prohibit copying and assigning instances of this clas
Done


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@299
PS1, Line 299: 
> Prefer allocating local helper objects on the stack, not on the heap.  If t
Done


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@653
PS1, Line 653:                                       exit_status, info_str));
> Should there be a check to enforce the invariant mentioned in the descripti
Done


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@683
PS1, Line 683: , fds.size());
             :   size_t i = 0;
> readability nit: prefer using strings::Substitute() here and elsewhere for 
Done


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@903
PS1, Line 903: 
> nit: for brevity, it's possible to use '{}' instead of explicitly calling t
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 11:04:31 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has removed a vote on this change.

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Removed Verified-1 by Kudu Jenkins (120)
-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: deleteVote
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 4
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 1: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3001/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 1
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 21 Sep 2026 14:33:43 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Hello Zoltan Chovan, Zoltan Martonka, Alexey Serbin, Gabriella Lotz, Attila Bukor, Kudu Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/24905

to look at the new patch set (#3).

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................

KUDU-3806: add deadline-bounded WaitAndCollect()

Add Subprocess::WaitAndCollect(), which concurrently drains the child's
piped stdout and stderr while waiting for it to exit, up to a deadline.
Draining both pipes together means a large write on one cannot deadlock
against a full buffer on the other; if the deadline passes first the
child is killed (SIGKILL), '*timed_out' is set, and whatever output was
collected so far is still returned.

To support this, ReadFdsFully() gains a deadline: a one-shot libev timer
(DeadlineHelper) breaks the drain loop when it fires, and each fd watcher
now decrements a shared open-count so the loop ends deterministically at
EOF even with the timer armed. An uninitialized deadline preserves the
historical "drain to EOF" behavior, which is what Subprocess::Call()
continues to pass.

This is groundwork for running each MCP tools/call in a bounded child
'kudu' process.

Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
M src/kudu/util/subprocess-test.cc
M src/kudu/util/subprocess.cc
M src/kudu/util/subprocess.h
3 files changed, 359 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/05/24905/3
-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 3:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3025/


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 12:58:01 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 3:

Build Aborted 

http://jenkins.kudu.apache.org/job/pre_commit/3020/ : ABORTED


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 12:03:08 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 4:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3037/


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 4
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Thu, 24 Sep 2026 12:48:04 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 2:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3013/


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 2
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 22 Sep 2026 12:20:20 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 3: Verified-1

Build Failed 

http://jenkins.kudu.apache.org/job/pre_commit/3025/ : FAILURE


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 14:34:58 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 4: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 4
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Fri, 25 Sep 2026 16:51:23 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Gabriella Lotz (Code Review)" <ge...@cloudera.org>.
Gabriella Lotz has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 4: Code-Review+1

(1 comment)

http://gerrit.cloudera.org:8080/#/c/24905/3/src/kudu/util/subprocess-test.cc
File src/kudu/util/subprocess-test.cc:

http://gerrit.cloudera.org:8080/#/c/24905/3/src/kudu/util/subprocess-test.cc@265
PS3, Line 265:   ASSERT_OK(p.WaitAndCollect(MonoDelta::FromSeconds(1),
             :                              &out, &err, &timed_out, &wait_status));
> Honestly I wasn't sure. I've submitted: ./bin/subprocess-test --stress_cpu_
It is satisfactory for me, thank you for running it.



-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 4
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Fri, 25 Sep 2026 12:44:51 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 1:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3001/


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 1
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Mon, 21 Sep 2026 13:29:16 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 3:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/3020/


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 3
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Wed, 23 Sep 2026 11:03:48 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 4: Verified+1

unrelated test failures:
asan: master_replication-itest.0, kudu-tool-test.3,
tsan: org.apache.kudu.client.TestSecurity


-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 4
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 28 Sep 2026 10:46:04 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................


Patch Set 2: Code-Review+1

(9 comments)

http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess-test.cc
File src/kudu/util/subprocess-test.cc:

http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess-test.cc@173
PS1, Line 173:   EXPECT_FALSE(timed_out);
             :   EXPECT_EQ("out\n", out);
             :   EXPECT_EQ("err\n", err);
             :   ASSERT_TRUE(WIFEXITED(wait_status));
             :   EXPECT_EQ(0, WEXITSTATUS(wait_status));
Here and below: what's the reason behind this mix of EXPECT_xxx and ASSERT_xxx?


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess-test.cc@241
PS1, Line 241: }
One more test scenario that I'd think of adding is this:
  * a sub-process runs and outputs some data into its stdout/stderr
  * the sub-process times out
  * WaitAndCollect() returns Status::OK() as expected, detects the timeout, and returns the data that's been output to the sub-process's stdout/stderr as expected

For the sub-process's output, there might be two options:
  * a static output that's easy to verify against the reference
  * dynamic output such as `while true; do echo "x"; sleep 1; done` or similar: the point here isn't verifying against the expected reference, but rather make sure nothing funny happens with the readers when timeout happens, making sure WaitAndCollect returns Status::OK() even if there was some pending data to be read when the timeout struck.

What do you think?


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess-test.cc@242
PS1, Line 242: 
In the context of covering edge cases, does it make sense to add a test scenario that starts a sub-process that's running for some time (e.g., similar to TestWaitAndCollectTimeout that runs for 1000 seconds) and then calls WaitAndCollect on it with a deadline that's already in the past at the time of starting the subprocess?

IIUC, it should behave simlar to TestWaitAndCollectTimeout, but it might make sense to have explicit coverage for such a corner case.


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.h
File src/kudu/util/subprocess.h:

http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.h@148
PS1, Line 148: MonoTime
In all the call sites of WaitAndCollect, it's necessary to first find current time, then add necessary MonoDelta, and then pass it as the 'deadline' argument for this function.  And the delta is re-computed from MonoTime into MonoDelta before calling corresponding libev function.

Do we really want the absolute time notation for deadline or we might rather prefer the delta notation (i.e. using MonoDelta) here?


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc
File src/kudu/util/subprocess.cc:

http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@268
PS1, Line 268: };
Does it make sense to prohibit copying and assigning instances of this class?  Can copies of ev::timer with the same dynamic loop introduce some sort of UB?


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@299
PS1, Line 299: new DeadlineHelper
Prefer allocating local helper objects on the stack, not on the heap.  If the optional semantics is required, use the std::optional<T> wrapper.

One of the reasons is contention in tcmalloc under heavy load and concurrency; in this case it's not crucial, though.


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@653
PS1, Line 653:   // Collect only the streams the caller asked for; each must be piped (i.e. not
Should there be a check to enforce the invariant mentioned in the description:

  The deadline is enforced while draining the pipes, so at least one of 'stdout_out'/'stderr_out' must be non-null for it to bound a child that neither exits nor writes.


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@683
PS1, Line 683: "failed to kill timed-out child " << program_ << ": "
             :                    << s.ToString();
readability nit: prefer using strings::Substitute() here and elsewhere for formatting the log message


http://gerrit.cloudera.org:8080/#/c/24905/1/src/kudu/util/subprocess.cc@903
PS1, Line 903: MonoTime()
nit: for brevity, it's possible to use '{}' instead of explicitly calling the named type's constructor, 'MonoTime()'



-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 2
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 22 Sep 2026 19:58:40 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-3806: add deadline-bounded WaitAndCollect()

Posted by "Marton Greber (Code Review)" <ge...@cloudera.org>.
Marton Greber has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/24905 )

Change subject: KUDU-3806: add deadline-bounded WaitAndCollect()
......................................................................

KUDU-3806: add deadline-bounded WaitAndCollect()

Add Subprocess::WaitAndCollect(), which concurrently drains the child's
piped stdout and stderr while waiting for it to exit, up to a deadline.
Draining both pipes together means a large write on one cannot deadlock
against a full buffer on the other; if the deadline passes first the
child is killed (SIGKILL), '*timed_out' is set, and whatever output was
collected so far is still returned.

To support this, ReadFdsFully() gains a deadline: a one-shot libev timer
(DeadlineHelper) breaks the drain loop when it fires, and each fd watcher
now decrements a shared open-count so the loop ends deterministically at
EOF even with the timer armed. An uninitialized deadline preserves the
historical "drain to EOF" behavior, which is what Subprocess::Call()
continues to pass.

This is groundwork for running each MCP tools/call in a bounded child
'kudu' process.

Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
Reviewed-on: http://gerrit.cloudera.org:8080/24905
Reviewed-by: Gabriella Lotz <lo...@gmail.com>
Reviewed-by: Alexey Serbin <al...@apache.org>
Tested-by: Marton Greber <gr...@gmail.com>
---
M src/kudu/util/subprocess-test.cc
M src/kudu/util/subprocess.cc
M src/kudu/util/subprocess.h
3 files changed, 359 insertions(+), 21 deletions(-)

Approvals:
  Gabriella Lotz: Looks good to me, but someone else must approve
  Alexey Serbin: Looks good to me, approved
  Marton Greber: Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/24905
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I582ea89b0ada4f723695df8d98d7e5bc0bbc7f7f
Gerrit-Change-Number: 24905
Gerrit-PatchSet: 5
Gerrit-Owner: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Attila Bukor <ab...@apache.org>
Gerrit-Reviewer: Gabriella Lotz <lo...@gmail.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Marton Greber <gr...@gmail.com>
Gerrit-Reviewer: Zoltan Chovan <zc...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>