Repository navigation
[BEAM-5850] Add QueueingBeamFnDataClient and make process, finish and start run on the same thread to support metrics. - #6786
Conversation
| @@ -0,0 +1,5 @@ | |||
| distributionBase=GRADLE_USER_HOME | |||
There was a problem hiding this comment.
Can you add these to .gitignore so that they are never added whenever someone clicks the button "enable something something with Gradle" in Intellij
f5e9dd1 to
01ff6f7
Compare
|
retest this please. |
|
I was able to run this test successfully locally like this: I will try with the apache testing project ./gradlew :beam-runners-google-cloud-dataflow-java-examples-streaming:preCommit -PgcpProject=google.com:clouddfe -PgcsTempRoot=gs://ajamato_presubmit/testing |
|
Yeah, I was able to get it to pass After authenticating properly |
|
retest this please |
0790ae2 to
53cc74d
Compare
d8c6a91 to
7da5610
Compare
|
|
||
| // TODO(BEAM-5972). Make sure that the apiServiceDescriptor is the same. | ||
| // throughout all references in the InstructionRequest | ||
| if (apiServiceDescriptor != null) { |
There was a problem hiding this comment.
I would think this would always be true for a real bundle, is this check only here because some of our unit tests don't construct valid ProcessBundleDescriptors?
If yes, it may be better to fix those unit tests instead so that we don't introduce a bug later on.
There was a problem hiding this comment.
See the new code now, I no longer need to lookup the apiServiceDescriptor.
|
Generally the direction of this PR has be a bit concerned. While it is convenient for users to be able to access and update metrics without having to reference an explicit context, I would definitely prefer that all internal access is explicit (e.g. no worrying about incrementing the wrong bundle's counter because you happened to be on the wrong thread). Forcing these executions to happen on the same thread just propagates this implicit assumption rather than cleaning it up. I think it'd be much cleaner to enter (and exit) the appropriate context on the desired thread (which presumably we'd be doing for state sampling anyway). In addition, adding extra buffers and queues is likely to hurt performance and makes understanding and debugging the system much harder and raises issues like how one should appropriately size and bound these queues. Is this the only (or at least best) way to support metrics? |
|
@robertwb This to address a gap in the current Java SDK. The thread that executes StartBundle/FinishBundle calls is different from the thread that the calls ProcessElement breaking the thread safety expectations of DoFn authors. This does make it easier to implement the metrics API as it exists today but that is a side effect. |
|
On Tue, Nov 13, 2018 at 6:35 PM Lukasz Cwik ***@***.***> wrote:
@robertwb <https://github.com/robertwb> This to address a gap in the
current Java SDK. The thread that executes StartBundle/FinishBundle calls
is different from the thread that the calls ProcessElement breaking the
thread safety expectations of DoFn authors.
Is this part of the contract? My understanding was that different threads
could be used, just not concurrently.
This does make it easier to use implement the metrics API as it exists
today but that is a side effect.
That's not how I read the title, but if this is where we want to go anyway
that's more OK (though the operational downsides still stand).
|
c2908e0 to
c593a7a
Compare
5f4f2c9 to
2426a63
Compare
2426a63 to
0de597d
Compare
| } | ||
| }); | ||
|
|
||
| receiveAllValuesB.await(); |
There was a problem hiding this comment.
Add timeout. Otherwise this can hang the test indefinitely.
Apply this to other awaits as well.
There was a problem hiding this comment.
Done, added test timeout annotation. Thanks
|
|
||
| boolean intentionallyFailedB = false; | ||
| try { | ||
| readFutureB.awaitCompletion(); // All InboundDataClients should be completed. |
| try { | ||
| readFutureB.awaitCompletion(); // All InboundDataClients should be completed. | ||
| } catch (RuntimeException e) { | ||
| intentionallyFailedB = true; |
There was a problem hiding this comment.
Why would B be intentionally failed, does it propagate exception from A?
There was a problem hiding this comment.
adding comment
// Fail all InboundObservers if any of the downstream consumers fail.
// This allows the ProcessBundlerHandler to unblock everything and fail properly.
| } | ||
|
|
||
| @Test | ||
| public void testBundleExecutionFailure() throws Exception { |
There was a problem hiding this comment.
Using test names in the form of <does_something><when_something_happens> usually makes tests more readable with additional benefit of:
- Defines expected behavior
- Simplifies triaging of test failure to the level when reading test name might be enough.
- Surves as inline test description.
I suggest renaming this to "testBundleProcessorThrowsExecutionExceptionWhenUserCodeThrows"
This applies to other tests names as well.
| })) | ||
| .apply("gbk", GroupByKey.create()); | ||
|
|
||
| RunnerApi.Pipeline pipelineProto = PipelineTranslation.toProto(p); |
There was a problem hiding this comment.
[No action comment]
Do I understand correctly that you build bundle to process?
If it is, it might be useful to extract such code to share between tests. I might reuse it in some other places.
There was a problem hiding this comment.
Ack, good idea. Though I am not sure how to best do this. We can design this together if you would like
| startFunction.run(); | ||
| } | ||
|
|
||
| if (hasReadPTransform) { |
There was a problem hiding this comment.
This should not be needed. queueingClient should handle case with no read ptransforms fine.
|
|
||
| private final BeamFnDataClient mainClient; | ||
| private final SynchronousQueue<ConsumerAndData> queue; | ||
| private final ConcurrentHashMap<InboundDataClient, Object> idcs; |
There was a problem hiding this comment.
rename to "dataClients" or "inboundDataClients".
It is not that much of text increase, but simplifies reading. I had to search several times for what does idcs mean.
| inputLocation.getInstructionId(), | ||
| inputLocation.getTarget()); | ||
|
|
||
| QueueingFnDataReceiver<T> queueingConsumer = new QueueingFnDataReceiver<T>(consumer); |
There was a problem hiding this comment.
Rename to queueingDataReceiver
There was a problem hiding this comment.
This is synonymous. Not renaming. Consumer and receiver are used throughout the whole code base. Doing an entire code base rename would be worth doing if we pick and enforce a single term
632abf5 to
ab6140f
Compare
|
Run Java PreCommit |
1 similar comment
|
Run Java PreCommit |
Ardagan
left a comment
There was a problem hiding this comment.
I believe some of your changes were lost during rebase. Please revisit my comments above one more time.
|
Run Java Precommit |
ab6140f to
f73a388
Compare
Ardagan
left a comment
There was a problem hiding this comment.
_~
_~ )_)_~
)_))_))_)
_!__!__!_
\______t/
5ed71e3 to
9776ed4
Compare
…n the same thread to support metrics.
9776ed4 to
e2731a4
Compare
|
Run Java PreCommit |
|
Failed precommit: https://builds.apache.org/job/beam_PreCommit_Java_Phrase/468/ |
|
Run Java PreCommit |
1 similar comment
|
Run Java PreCommit |
Update BeamFnDataReceiver to place elements into a Queue and consumer then and call the element processing receiver in blockTillReadFinishes. This supports the user metrics API which depends on a same thread context for process, start and finish.
Follow this checklist to help us incorporate your contribution quickly and easily:
[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.It will help us expedite review of your Pull Request if you tag someone (e.g.
@username) to look at it.Post-Commit Tests Status (on master branch)