[BEAM-4347] Enforce ErrorProne analysis in kafka IO#5422
[BEAM-4347] Enforce ErrorProne analysis in kafka IO#5422iemejia merged 4 commits intoapache:masterfrom
Conversation
|
R: @rangadi Can you please take a look at this one since it is Kafka related. |
rangadi
left a comment
There was a problem hiding this comment.
Thanks for doing this @timrobertson100. Left a few comments (TODO comments and checking if switch to 'ArrayList' is required)
@iemejia, LGTM overall.
| ProducerSpEL.beginTransaction(producer); | ||
| } | ||
|
|
||
| @SuppressWarnings("FutureReturnValueIgnored") |
There was a problem hiding this comment.
Please leave a TODO for me.
// TODO : rangadi : add explanation for why this is ok.
Can we make this send() return future and ignore it at the call site?
There was a problem hiding this comment.
In general I'm not much in favour of leaving TODOs within code (looks cluttered, doesn't help with tracking outstanding work etc).
How about I open a jira task to review future handling in KafkaIO, informing that we've suppressed warnings (doesn't change current behaviour) but would like to review if we may drop messages on exceptional cases? I'll be happy to dig deeper with you on that.
There was a problem hiding this comment.
Makes sense. Please file a jira. I wanted to add the comment soon after this gets merged. I know why it is ok to ignore here (it will be waited on inside commitTxn()). You can add the explanation in PR itself. If you are adding the comment, I suggest changing sendRecord() return the future and let the call ignore it with a comment saying they are flushed in commitTxn().
There was a problem hiding this comment.
I'll make the code change - new commit later
| * closed if it is stays in cache for more than 1 minute, i.e. not used inside | ||
| * KafkaExactlyOnceSink DoFn for a minute. | ||
| */ | ||
| @SuppressWarnings("FutureReturnValueIgnored") |
There was a problem hiding this comment.
I don't see where a Future is ignored. Please leave a comment :
// TODO : rangadi : review if this is even required.
There was a problem hiding this comment.
FYI: It's needed because of the SCHEDULED_CLEAN_UP_THREAD.scheduleAtFixedRate(...)
There was a problem hiding this comment.
Please add a comment to that effect. Will be useful for other readers.
| } | ||
|
|
||
| @ProcessElement | ||
| @SuppressWarnings("FutureReturnValueIgnored") |
There was a problem hiding this comment.
// TODO : rangadi : explain why this is ok.
There was a problem hiding this comment.
As above - can I include this in a Review future handling in KafkaIO Jira instead please?
There was a problem hiding this comment.
Yes, either jira, or better, you can add a comment. Reason it is ok to ignore here is that SendCallback() keeps track of failures, which are checked inside finishBundle().
|
|
||
| // cycle through the partitions in order to interleave records from each. | ||
| curBatch = Iterators.cycle(new LinkedList<>(partitionStates)); | ||
| curBatch = Iterators.cycle(new ArrayList<>(partitionStates)); |
There was a problem hiding this comment.
Was this also recommended by ErrorProne?
There was a problem hiding this comment.
Yes.
LinkedListalmost never out-performsArrayListorArrayDeque. If you are usingLinkedListas a list, preferArrayList. If you are usingLinkedListas a stack or queue/deque, preferArrayDeque.
Because ArrayDeque rejects nulls I erred on the side of caution
There was a problem hiding this comment.
We are using LinkedList because of elements deleted in random order (in advance()). There are no nulls. Was it an ErrorProne error?
Overall I don't think the difference matters at all either way. I would be surprised if ErrorProne insisted we change it.
There was a problem hiding this comment.
Error prone reports it as warning but we now fail builds on warning (unless suppressed of course). Thanks for confirming no nulls.
| (record -> new Instant(TimeUnit.SECONDS.toMillis(record.getKV().getValue()) | ||
| + customTimestampStartMillis)), | ||
| Duration.millis(0), | ||
| Duration.ZERO, |
There was a problem hiding this comment.
Just curious: ErrorProne suggested this?
There was a problem hiding this comment.
Yes.
It offers some nice suggestions for readability I've found (e.g. seconds(180) -> minutes(3))
|
Thanks for the review @rangadi If you're ok with the proposal I create a Jira for a review of Future handling in |
|
Commented. Since you are interested, simpler thing might be to add the explanations for ignoring futures in this PR itself. JIRA is also fine. |
|
Thanks @rangadi. I'll make a few changes and provide another commit (probably tomorrow or Tuesday) |
|
Please can you take a look @rangadi ? |
rangadi
left a comment
There was a problem hiding this comment.
LGTM. Suggested two minor changes : removing 'Note:' in comments and reverting ArrayDeque change.
| KafkaExactlyOnceSink.ensureEOSSupport(); | ||
| } | ||
|
|
||
| // Note: Futures ignored as exceptions will be flushed out in the commitTxn |
There was a problem hiding this comment.
A short comment is already a note :). We could remove them.
|
|
||
| // cycle through the partitions in order to interleave records from each. | ||
| curBatch = Iterators.cycle(new ArrayList<>(partitionStates)); | ||
| curBatch = Iterators.cycle(new ArrayDeque<>(partitionStates)); |
There was a problem hiding this comment.
This list is neither used as a stack or nor as a queue. I would say you can either leave it as ArrayList or LinkedList. ArrayDeque incorrectly implies usage.
|
Thanks for review @rangadi - those changes now applied. |
| } | ||
|
|
||
| // Note: Suppression since rrrors are tracked in SendCallback(), and checked on finishBundle() | ||
| // Suppression since rrrors are tracked in SendCallback(), and checked on finishBundle() |
There was a problem hiding this comment.
typo in 'errors'. Also 'in finishBundle()'?.
|
LGTM. Thanks @timrobertson100. |
|
Oups I screwed the correct title by double clicking merge by mistake. Thanks @timrobertson100 and @rangadi for the proper review. |
|
LGTM in postfix mode due to my sloppy fingers. |
A simple PR to enforce error prone and fail the build on warnings raised. Current
errorpronewarnings are fixed (but I did not do an IDEA code analysis in this editing round).CC @iemejia @swegner - could you please assign a reviewer?