Skip to content

MINOR: Fix ProcessorContext JavaDocs#8603

Merged
mjsax merged 2 commits into
apache:trunkfrom
mjsax:minor-update-processorcontext-javadocs
May 12, 2020
Merged

MINOR: Fix ProcessorContext JavaDocs#8603
mjsax merged 2 commits into
apache:trunkfrom
mjsax:minor-update-processorcontext-javadocs

Conversation

@mjsax

@mjsax mjsax commented May 2, 2020

Copy link
Copy Markdown
Member

We changed how "stream time" is computed in 2.3 release. This should be cherry-picked to older branches.

@mjsax mjsax added the streams label May 2, 2020
@mjsax

mjsax commented May 2, 2020

Copy link
Copy Markdown
Member Author

Call for review @vvcephei

@mjsax

mjsax commented May 4, 2020

Copy link
Copy Markdown
Member Author

Java 8 and 14 passed.
Java 11: org.apache.kafka.connect.mirror.MirrorConnectorsIntegrationTest.testReplication

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

Thanks for this, @mjsax !

I was a little surprised by the new definition, so I did a little digging, and wound up digging up a problem. WDYT?

* <p> If it is triggered while processing a record generated not from the source processor (for example,
* if this method is invoked from the punctuate call), timestamp is defined as the current
* task's stream time, which is defined as the smallest among all its input stream partition timestamps.
* task's stream time, which is defined as the largest among all its input stream partition timestamps.

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.

I just took another look at the definition of streamTime, and it actually looks like it might be computed wrongly.

The way it works is that the "stream time" for a task is computed most of the time in org.apache.kafka.streams.processor.internals.PartitionGroup#nextRecord, i.e., it's the max timestamp of any record polled from the PartitionGroup.

However, when we commit, we commit the "partition time" for each TopicPartition, which is set when we move a record into the head position for that queue. During restoration, we read these committed timestamps for each TopicPartition, and we (incorrectly) set the "stream time" to be the maximum over the "partition time" of each partition in the PartitionGroup (aka Task).

This is incorrect in two ways:

  1. it should be the minimum, not the maximum (since we would choose the record with the minimum timestamp to process next)
  2. the timestamp of the head enqueued record (partition time) is not the timestamp of the last dequeued record (stream time).

I'll file a Jira ticket capturing all this. In the mean time, I'd suggest that we just update the docs to reflect the correct definition of "stream time": which is defined as the largest timestamp of any record processed by the task. Then, we can fix the code to make this true all the time. Currently, it's only true in steady state, not immediately after restoration.

@mjsax mjsax May 5, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sound like a bug :)

But it seems to be a one line fix that I can piggy-back on this PR. We advance the "partition time" too early. If we advance it when the return the record for processing, all should be fixed? Partition time should not be the head-record timestamp but the past processed record of the partition.

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.

Ah, perfect! This is much simpler than what I was thinking. Thanks.

@mjsax

mjsax commented May 6, 2020

Copy link
Copy Markdown
Member Author

@vvcephei Updates this.

@mjsax

mjsax commented May 7, 2020

Copy link
Copy Markdown
Member Author

Java 8: org.apache.kafka.streams.integration.GlobalKTableEOSIntegrationTest.shouldKStreamGlobalKTableJoin[exactly_once_beta]
Java 11: timed out
Java 14:

org.apache.kafka.streams.integration.EosBetaUpgradeIntegrationTest.shouldUpgradeFromEosAlphaToEosBeta[true]
org.apache.kafka.streams.integration.GlobalKTableIntegrationTest.shouldKStreamGlobalKTableLeftJoin

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

Thanks, @mjsax ! The new docs and the bugfix look great to me.

@mjsax

mjsax commented May 12, 2020

Copy link
Copy Markdown
Member Author

Retest this please.

@mjsax
mjsax merged commit 778d04d into apache:trunk May 12, 2020
@mjsax
mjsax deleted the minor-update-processorcontext-javadocs branch May 12, 2020 22:19
Kvicii added a commit to Kvicii/kafka that referenced this pull request May 14, 2020
* 'trunk' of github.com:apache/kafka:
  MINOR: add option to rebuild source for system tests (apache#6656)
  KAFKA-9850 Move KStream#repartition operator validation during Topolo… (apache#8550)
  MINOR: Add a duplicate() method to Message classes (apache#8556)
  KAFKA-9966: add internal assignment listener to stabilize eos-beta upgrade test (apache#8648)
  MINOR: Replace null with an actual value for timestamp field in InsertField SMT unit tests (apache#8649)
  MINOR: Fix ProcessorContext JavaDocs and stream-time computation (apache#8603)
  MINOR: improve tests for TopologyTestDriver (apache#8631)
  KAFKA-9821: consolidate Streams rebalance triggering mechanisms (apache#8596)
  KAFKA-9669; Loosen validation of inner offsets for older message formats (apache#8647)
  KAFKA-8770: KIP-557: Drop idempotent KTable source updates (apache#8254)
  MINOR: Remove allow concurrent test (apache#8641)
jwijgerd pushed a commit to buxapp/kafka that referenced this pull request May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants