Skip to content

_cas: avoid blocking calls to long grpc methods - #2160

Merged
abderrahim merged 1 commit into
masterfrom
abderrahim/pull-push-hang
Aug 6, 2026
Merged

_cas: avoid blocking calls to long grpc methods#2160
abderrahim merged 1 commit into
masterfrom
abderrahim/pull-push-hang

Conversation

@abderrahim

@abderrahim abderrahim commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Long-running synchronous grpc calls block the thread where they are
called, which can cause the scheduler to be unable to terminate the
job.

This commit replaces them with usage of the "asynchronous" future
API. The result() method of a grpc future will not block the thread
while it's waiting, and thus allows terminating the job without
waiting for the blocking call to return. This covers the LocalCAS
methods {Fetch,Upload}{Tree,MissingBlobs}.

As an added benefit, we try to cancel the grpc calls when
terminated. This depends on the server side (buildbox-casd) promptly
cancelling the remote calls, which it doesn't consistently do at the
moment. But that can be fixed independently.

Fixes #2157

Comment thread src/buildstream/_cas/casremote.py
Comment thread src/buildstream/_cas/casremote.py Outdated
@abderrahim
abderrahim force-pushed the abderrahim/pull-push-hang branch 3 times, most recently from c5f3504 to fbe5aeb Compare August 4, 2026 15:13
@abderrahim abderrahim changed the title casremote: avoid blocking calls to {Fetch,Upload}MissingBlobs _cas: avoid blocking calls to long grpc methods Aug 4, 2026
@abderrahim
abderrahim force-pushed the abderrahim/pull-push-hang branch from fbe5aeb to b1b8fa0 Compare August 4, 2026 15:15
@abderrahim
abderrahim marked this pull request as ready for review August 4, 2026 15:15
@abderrahim
abderrahim force-pushed the abderrahim/pull-push-hang branch from b1b8fa0 to 50f97b8 Compare August 5, 2026 10:30

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

LGTM

Long-running synchronous grpc calls block the thread where they are
called, which can cause the scheduler to be unable to terminate the
job.

This commit replaces them with usage of the "asynchronous" future
API. The result() method of a grpc future will not block the thread
while it's waiting, and thus allows terminating the job without
waiting for the blocking call to return. This covers the LocalCAS
methods {Fetch,Upload}{Tree,MissingBlobs}, and the CAS method
FindMissingBlobs.

As an added benefit, we try to cancel the grpc calls when
terminated. This depends on the server side (buildbox-casd) promptly
cancelling the remote calls, which it doesn't consistently do at the
moment. But that can be fixed independently.

Fixes #2157
@abderrahim
abderrahim force-pushed the abderrahim/pull-push-hang branch from 50f97b8 to 7a79c78 Compare August 6, 2026 14:56
@abderrahim
abderrahim merged commit 344cac6 into master Aug 6, 2026
34 of 36 checks passed
@abderrahim
abderrahim deleted the abderrahim/pull-push-hang branch August 6, 2026 21:07
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.

Can't stop artifact pulls sometimes

2 participants