Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output directories are sometimes out of order when using remote execution #5109

Closed
jjudd opened this issue Apr 27, 2018 · 7 comments
Closed
Assignees

Comments

@jjudd
Copy link
Contributor

jjudd commented Apr 27, 2018

Description of the problem:

When using remote execution (buildfarm) output directories are sometimes out of order. The spec requires them to be lexicographically sorted.

I have a PR that fixes this issue and will link it after creating this issue.

When using remote executing, a parent node is built from action inputs in TreeNodeRepository. The files are sorted by path in RemoteSpawnRunner. These paths are then broken down into segments and a tree structure is created from the segments.

Problem is, the segments at each level of the tree structure are not sorted before they are added to the parent node. This can result in an unordered directory tree.

For example, the sort order of this list of files

/foo/bar-client/bar-client_ijar.jar
/foo/bar/bar_ijar.jar

is maintained when it becomes a tree structure

foo ->
    bar-client ->
        bar-client_ijar.jar
    bar
        bar_ijar.jar

which is out of order.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create a Bazel project with two packages

/foo/bar-client
/foo/bar

that produce outputs named in a similar fashion. For example, two Java targets that create:

/foo/bar-client/bar-client_ijar.jar
/foo/bar/bar_ijar.jar

Then build those targets using buildfarm or another remote executor. You will receive an error like the following:

Caused by: io.grpc.StatusRuntimeException: FAILED_PRECONDITION: The files in an input `Directory` are not correctly sorted by `name`.
	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:221)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:202)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:131)
	at com.google.devtools.remoteexecution.v1test.ExecutionGrpc$ExecutionBlockingStub.execute(ExecutionGrpc.java:370)
	at com.google.devtools.build.lib.remote.GrpcRemoteExecutor.lambda$executeRemotely$0(GrpcRemoteExecutor.java:133)
	at com.google.devtools.build.lib.remote.Retrier.execute(Retrier.java:220)
	at com.google.devtools.build.lib.remote.RemoteRetrier.execute(RemoteRetrier.java:101)
	at com.google.devtools.build.lib.remote.GrpcRemoteExecutor.lambda$executeRemotely$2(GrpcRemoteExecutor.java:133)
	at com.google.devtools.build.lib.remote.Retrier.execute(Retrier.java:220)
	... 21 more

What operating system are you running Bazel on?

Ubuntu 16.04 x86_64

What's the output of bazel info release?

$ bazel info release
.........
release 0.12.0

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

james@james:~/opensource/bazel$ git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
git@github.com:bazelbuild/bazel.git
ca76428fe83f73f2428d4fdc1382884108de4fed
ca76428fe83f73f2428d4fdc1382884108de4fed
jjudd pushed a commit to lucidsoftware/bazel that referenced this issue Apr 27, 2018
…red directory structures.

When building a parent node from action inputs, the paths to the files are
sorted. These paths are then broken down into segments and a tree structure
is created from the segments.

Problem is, the segments at each level of the tree structure are not sorted
before they are added to the parent node. This can result in an unordered
directory tree.

For example, the sort order of this list of files
/foo/bar-client/bar-client_ijar.jar
/foo/bar/bar_ijar.jar

is maintained when it becomes a tree structure
foo ->
    bar-client ->
        bar-client_ijar.jar
    bar
        bar_ijar.jar

which is out of order.

Resolves: bazelbuild#5109
@jjudd
Copy link
Contributor Author

jjudd commented Apr 27, 2018

Here is a PR that fixes this issue: #5110

@iirina
Copy link
Contributor

iirina commented May 2, 2018

Thanks for the PR! I assigned you since you sent a fix.

meteorcloudy pushed a commit that referenced this issue May 7, 2018
…red directory structures.

When building a parent node from action inputs, the paths to the files are
sorted. These paths are then broken down into segments and a tree structure
is created from the segments.

Problem is, the segments at each level of the tree structure are not sorted
before they are added to the parent node. This can result in an unordered
directory tree.

For example, the sort order of this list of files
```
/foo/bar-client/bar-client_ijar.jar
/foo/bar/bar_ijar.jar
```

is maintained when it becomes a tree structure
```
foo ->
    bar-client ->
        bar-client_ijar.jar
    bar
        bar_ijar.jar
```
which is out of order.

Resolves: #5109

Closes #5110.

PiperOrigin-RevId: 195649710
@driveraid
Copy link

Is this fixed? I still see the issue on Bazel 0.13.0 with bazel buildfarm rev 24a5d7e29.

@jjudd
Copy link
Contributor Author

jjudd commented May 7, 2018

The fix for this was merged a few hours ago. It hasn't been released as far as I know. If you're running off of HEAD, then it should be fixed.

@driveraid
Copy link

Sorry, I was confused about the reference to the 0.13.0 release above.. :)

werkt pushed a commit to werkt/bazel that referenced this issue May 9, 2018
…red directory structures.

When building a parent node from action inputs, the paths to the files are
sorted. These paths are then broken down into segments and a tree structure
is created from the segments.

Problem is, the segments at each level of the tree structure are not sorted
before they are added to the parent node. This can result in an unordered
directory tree.

For example, the sort order of this list of files
/foo/bar-client/bar-client_ijar.jar
/foo/bar/bar_ijar.jar

is maintained when it becomes a tree structure
foo ->
    bar-client ->
        bar-client_ijar.jar
    bar
        bar_ijar.jar

which is out of order.

Resolves: bazelbuild#5109
@driveraid
Copy link

Seems released in https://github.com/bazelbuild/bazel/releases/tag/0.13.1 right?

"Important changes:

Remote Execution: Fixes a regression that produces directories with unsorted file/directory lists"

@buchgr
Copy link
Contributor

buchgr commented May 28, 2018

@driveraid yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants