You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/09/02 11:34:54 UTC
[GitHub] [flink] syhily opened a new pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
syhily opened a new pull request #17119:
URL: https://github.com/apache/flink/pull/17119
## What is the purpose of the change
Pulsar would disconnect the existed consumer when we perform a seek operation on a topic partition. If we have multiple consumers with the same subscription, we may meet a consumer not found error. That means Pulsar doesn't support seek on a partition with the same subscription concurrently. Move the seek operation to enumerator would make sure all the partitions would be executed one by one and only once. Thus fixed the test issue.
## Brief change log
- Drop `StartCursor` in `PulsarPartitionSplit`.
- Move `Consumer.seek` to source enumerator.
## Verifying this change
This change is already covered by existing tests, such as *PulsarSourceITCase*.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes)
- The serializers: (yes)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (don't know)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
- If yes, how is the feature documented? (not applicable)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
}, {
"hash" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"triggerType" : "PUSH"
}, {
"hash" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479",
"triggerID" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 87e3f1eba6e972cf4fde5e65e95d45eeffdee013 UNKNOWN
* 6c4aa79c4cc1d785bc46787bf730c7dc74f01f78 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
AHeise commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r703525392
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -175,11 +175,11 @@ public void close() {
private void seekStartPosition(Set<TopicPartition> partitions) {
ConsumerBuilder<byte[]> consumerBuilder =
createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
- Set<String> seekedPartitions = new HashSet<>();
+ Set<String> seekedTopics = new HashSet<>();
for (TopicPartition partition : partitions) {
String topicName = partition.getFullTopicName();
- if (seekedPartitions.add(topicName)) {
+ if (!assignmentState.containsTopic(topicName) && seekedTopics.add(topicName)) {
Review comment:
We could avoid this check by using only hooking into `assign` which only gets the added partitions. Did you try that out? (It might not work out, but it feels the better place).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
}, {
"hash" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"triggerType" : "PUSH"
}, {
"hash" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479",
"triggerID" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"triggerType" : "PUSH"
}, {
"hash" : "5815d6d35fb9fc6dae3a64f7e33b24f0034e0861",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "5815d6d35fb9fc6dae3a64f7e33b24f0034e0861",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 87e3f1eba6e972cf4fde5e65e95d45eeffdee013 UNKNOWN
* 6c4aa79c4cc1d785bc46787bf730c7dc74f01f78 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479)
* 5815d6d35fb9fc6dae3a64f7e33b24f0034e0861 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] syhily commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
syhily commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r702456944
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,42 @@ public void close() {
* @return Set of subscribed {@link TopicPartition}s
*/
private Set<TopicPartition> getSubscribedTopicPartitions() {
- return subscriber.getSubscribedTopicPartitions(
- pulsarAdmin, rangeGenerator, context.currentParallelism());
+ int parallelism = context.currentParallelism();
+ Set<TopicPartition> partitions =
+ subscriber.getSubscribedTopicPartitions(pulsarAdmin, rangeGenerator, parallelism);
+
+ // Seek start position for given partitions.
+ seekStartPosition(partitions);
Review comment:
Yep, you are totally right. This is my mistake.
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/split/PulsarOrderedPartitionSplitReader.java
##########
@@ -75,7 +78,30 @@ protected void finishedPollMessage(Message<byte[]> message) {
@Override
protected void startConsumer(PulsarPartitionSplit split, Consumer<byte[]> consumer) {
- initialStartPosition(split, consumer);
+ MessageId latestConsumedId = split.getLatestConsumedId();
+
+ // Reset the start position for ordered pulsar consumer.
+ if (latestConsumedId != null) {
+ StartCursor startCursor = StartCursor.fromMessageId(latestConsumedId, false);
+ TopicPartition partition = split.getPartition();
+
+ try {
+ startCursor.seekPosition(
+ partition.getTopic(), partition.getPartitionId(), consumer);
Review comment:
I have changed the serialization logic, the `latestConsumedId` shouldn't be `null` here when we restart.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
}, {
"hash" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"triggerType" : "PUSH"
}, {
"hash" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479",
"triggerID" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"triggerType" : "PUSH"
}, {
"hash" : "5815d6d35fb9fc6dae3a64f7e33b24f0034e0861",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23656",
"triggerID" : "5815d6d35fb9fc6dae3a64f7e33b24f0034e0861",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 87e3f1eba6e972cf4fde5e65e95d45eeffdee013 UNKNOWN
* 6c4aa79c4cc1d785bc46787bf730c7dc74f01f78 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479)
* 5815d6d35fb9fc6dae3a64f7e33b24f0034e0861 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23656)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
AHeise commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r704447651
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -175,11 +175,11 @@ public void close() {
private void seekStartPosition(Set<TopicPartition> partitions) {
ConsumerBuilder<byte[]> consumerBuilder =
createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
- Set<String> seekedPartitions = new HashSet<>();
+ Set<String> seekedTopics = new HashSet<>();
for (TopicPartition partition : partitions) {
String topicName = partition.getFullTopicName();
- if (seekedPartitions.add(topicName)) {
+ if (!assignmentState.containsTopic(topicName) && seekedTopics.add(topicName)) {
Review comment:
Clarified offline that this would not be as straight-forward and will be eventually superseded by the protocol sketched above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
}, {
"hash" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"triggerType" : "PUSH"
}, {
"hash" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479",
"triggerID" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ed5fc47b3d324ca63da8ff25b93e8057d5ba8953 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406)
* 87e3f1eba6e972cf4fde5e65e95d45eeffdee013 UNKNOWN
* 6c4aa79c4cc1d785bc46787bf730c7dc74f01f78 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] syhily commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
syhily commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r701686082
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/split/PulsarOrderedPartitionSplitReader.java
##########
@@ -75,7 +78,30 @@ protected void finishedPollMessage(Message<byte[]> message) {
@Override
protected void startConsumer(PulsarPartitionSplit split, Consumer<byte[]> consumer) {
- initialStartPosition(split, consumer);
+ MessageId latestConsumedId = split.getLatestConsumedId();
+
+ // Reset the start position for ordered pulsar consumer.
+ if (latestConsumedId != null) {
+ StartCursor startCursor = StartCursor.fromMessageId(latestConsumedId, false);
+ TopicPartition partition = split.getPartition();
+
+ try {
+ startCursor.seekPosition(
+ partition.getTopic(), partition.getPartitionId(), consumer);
Review comment:
It's used only for `Exclusive` or `Failover` subscriptions. Only one consumer would be used for seeking the start position.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
AHeise commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r703523532
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -175,11 +175,11 @@ public void close() {
private void seekStartPosition(Set<TopicPartition> partitions) {
ConsumerBuilder<byte[]> consumerBuilder =
createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
- Set<String> seekedPartitions = new HashSet<>();
+ Set<String> seekedTopics = new HashSet<>();
Review comment:
Since this is a local variable, you still end up seeking the topics on each discovery.
It might be better to switch the call of this function to `assign...` as this is only called on the newly discovered partitions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
}, {
"hash" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"triggerType" : "PUSH"
}, {
"hash" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23479",
"triggerID" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"triggerType" : "PUSH"
}, {
"hash" : "5815d6d35fb9fc6dae3a64f7e33b24f0034e0861",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23656",
"triggerID" : "5815d6d35fb9fc6dae3a64f7e33b24f0034e0861",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 87e3f1eba6e972cf4fde5e65e95d45eeffdee013 UNKNOWN
* 5815d6d35fb9fc6dae3a64f7e33b24f0034e0861 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23656)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] syhily commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
syhily commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r701500537
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,44 @@ public void close() {
* @return Set of subscribed {@link TopicPartition}s
*/
private Set<TopicPartition> getSubscribedTopicPartitions() {
- return subscriber.getSubscribedTopicPartitions(
- pulsarAdmin, rangeGenerator, context.currentParallelism());
+ int parallelism = context.currentParallelism();
+ Set<TopicPartition> partitions =
+ subscriber.getSubscribedTopicPartitions(pulsarAdmin, rangeGenerator, parallelism);
+
+ // Seek start position for given partitions.
+ seekStartPosition(partitions);
+
+ return partitions;
+ }
+
+ private void seekStartPosition(Set<TopicPartition> partitions) {
+ ConsumerBuilder<byte[]> consumerBuilder =
+ createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
+ Set<String> seekedPartitions = new HashSet<>();
+
+ for (TopicPartition partition : partitions) {
+ String topicName = partition.getFullTopicName();
Review comment:
If we use the Key_Shared subscription, the `topicName` could be duplicated. We would create the same topic partition with a different `TopicRange`.
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,44 @@ public void close() {
* @return Set of subscribed {@link TopicPartition}s
*/
private Set<TopicPartition> getSubscribedTopicPartitions() {
- return subscriber.getSubscribedTopicPartitions(
- pulsarAdmin, rangeGenerator, context.currentParallelism());
+ int parallelism = context.currentParallelism();
+ Set<TopicPartition> partitions =
+ subscriber.getSubscribedTopicPartitions(pulsarAdmin, rangeGenerator, parallelism);
+
+ // Seek start position for given partitions.
+ seekStartPosition(partitions);
+
+ return partitions;
+ }
+
+ private void seekStartPosition(Set<TopicPartition> partitions) {
+ ConsumerBuilder<byte[]> consumerBuilder =
+ createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
+ Set<String> seekedPartitions = new HashSet<>();
+
+ for (TopicPartition partition : partitions) {
+ String topicName = partition.getFullTopicName();
+ if (!seekedPartitions.contains(topicName)) {
+ try (Consumer<byte[]> consumer =
+ sneakyClient(() -> consumerBuilder.clone().topic(topicName).subscribe())) {
+ startCursor.seekPosition(
+ partition.getTopic(), partition.getPartitionId(), consumer);
+ } catch (PulsarClientException e) {
+ if (sourceConfiguration.getVerifyInitialOffsets() == FAIL_ON_MISMATCH) {
+ throw new IllegalArgumentException(e);
+ } else {
+ // WARN_ON_MISMATCH would just print this warning message.
+ // No need to print the stacktrace.
+ LOG.warn(
+ "Failed to set initial consuming position for partition {}",
+ partition,
+ e);
Review comment:
The seek exception could be multiple. Such as the timeout when connecting with the broker, bookie, etc. Print the exception would help us debug.
##########
File path: flink-connectors/flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/source/split/PulsarPartitionSplitTest.java
##########
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.connector.pulsar.source.split;
-
-import org.apache.flink.connector.pulsar.source.enumerator.cursor.CursorPosition;
-import org.apache.flink.connector.pulsar.source.enumerator.cursor.StartCursor;
-import org.apache.flink.connector.pulsar.source.enumerator.topic.TopicPartition;
-
-import org.apache.pulsar.client.impl.MessageIdImpl;
-import org.junit.jupiter.api.Test;
-
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
-import static org.apache.flink.connector.pulsar.source.enumerator.cursor.StartCursor.defaultStartCursor;
-import static org.apache.flink.connector.pulsar.source.enumerator.cursor.StopCursor.defaultStopCursor;
-import static org.apache.flink.connector.pulsar.source.enumerator.topic.TopicRange.createFullRange;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-/** Unit tests for {@link PulsarPartitionSplit}. */
-class PulsarPartitionSplitTest {
-
- @Test
- void partitionSplitWouldHaveANewStartCursorWhenCheckpointing() {
Review comment:
This test was originally used to check if the StartCursor was updated when the PulsarPartitionSplit was created, but now the StartCursor is no longer used in the Split, so the corresponding test is no longer necessary.
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/split/PulsarOrderedPartitionSplitReader.java
##########
@@ -75,7 +78,30 @@ protected void finishedPollMessage(Message<byte[]> message) {
@Override
protected void startConsumer(PulsarPartitionSplit split, Consumer<byte[]> consumer) {
- initialStartPosition(split, consumer);
+ MessageId latestConsumedId = split.getLatestConsumedId();
+
+ // Reset the start position for ordered pulsar consumer.
+ if (latestConsumedId != null) {
+ StartCursor startCursor = StartCursor.fromMessageId(latestConsumedId, false);
+ TopicPartition partition = split.getPartition();
+
+ try {
+ startCursor.seekPosition(
+ partition.getTopic(), partition.getPartitionId(), consumer);
Review comment:
seek in enumerator is the initial seek when we create the topic partition. This seek is used when we meet a restart or failure. We need to consume from the last successful checkpoint position.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise merged pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
AHeise merged pull request #17119:
URL: https://github.com/apache/flink/pull/17119
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
AHeise commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r704447651
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -175,11 +175,11 @@ public void close() {
private void seekStartPosition(Set<TopicPartition> partitions) {
ConsumerBuilder<byte[]> consumerBuilder =
createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
- Set<String> seekedPartitions = new HashSet<>();
+ Set<String> seekedTopics = new HashSet<>();
for (TopicPartition partition : partitions) {
String topicName = partition.getFullTopicName();
- if (seekedPartitions.add(topicName)) {
+ if (!assignmentState.containsTopic(topicName) && seekedTopics.add(topicName)) {
Review comment:
Clarified offline that this would not be as straight-forward and will be eventually superseded by the protocol sketched above. So we go with the current solution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
}, {
"hash" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ed5fc47b3d324ca63da8ff25b93e8057d5ba8953 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406)
* 87e3f1eba6e972cf4fde5e65e95d45eeffdee013 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] syhily commented on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
syhily commented on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-913198448
> I'm assuming that we need to have some messages between the readers and the enumerator:
>
> * The enumerator is not seeking at all.
> * Readers seek for exclusive subscriptions.
> * For non-exclusive subscriptions, a reader signals to enumerator that the topic partition needs initialization and the reader does not consume from that subscription initially.
> * Enumerator sends to all readers with the same topic partition some pause message (this is needed in case of regional failover).
> * Enumerator passes some initialization token to one of the readers that all want to seek the same topic partition.
> * That one reader seeks and informs enumerator.
> * Enumerator unpauses all readers of that TopicPartition.
> * Readers that have been paused need to ignore all message ids < pause message id (in case of regional failover)
This design is awesome. Move all the seek action in one place is better than the current solution. I have read the code. I think we need to implement the `SourceEvent`. But I may need some time to learn how to use it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] syhily commented on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
syhily commented on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-913197813
> I think we have an issue with non-exclusive topic partitions as-is:
>
> * If we have a full restart, it makes sense to reinitialize on the enumerator.
> * For partial restarts (regional failover), I don't see how we can plausibly initialize the reader:
> * If we initialize on enumerator, we interfere with non-failed subtasks.
> * If we initialize on the reader, we get the current issues.
> * If we don't initialize, it's probably incorrect as well
The issue of non-exclusive topic partitions doesn't exist. Let me clarify it. Consuming with the `Shared` or `Key_Shared` (on non-exclusive topic partitions) subscription would share the same partition among different readers. We can't use cumulative acknowledgment in these two modes, which means we have to mark the messages as read one by one.
Record all the consumed messages and marked as read after successfully performing checkpoint doesn't sound like a good design. So we use [Transaction](https://pulsar.apache.org/docs/en/txn-how/#3-acknowledge-messages-with-a-transaction) to solve this problem.
When we met partial restarts, the uncommitted Transaction would be abort, we would redeliver all the unacknowledged messages (the messages which don't mark read) by using `consumer.redeliverUnacknowledgedMessages()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ed5fc47b3d324ca63da8ff25b93e8057d5ba8953 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911572836
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit ed5fc47b3d324ca63da8ff25b93e8057d5ba8953 (Thu Sep 02 11:38:36 UTC 2021)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
AHeise commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r701318919
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,44 @@ public void close() {
* @return Set of subscribed {@link TopicPartition}s
*/
private Set<TopicPartition> getSubscribedTopicPartitions() {
- return subscriber.getSubscribedTopicPartitions(
- pulsarAdmin, rangeGenerator, context.currentParallelism());
+ int parallelism = context.currentParallelism();
+ Set<TopicPartition> partitions =
+ subscriber.getSubscribedTopicPartitions(pulsarAdmin, rangeGenerator, parallelism);
+
+ // Seek start position for given partitions.
+ seekStartPosition(partitions);
+
+ return partitions;
+ }
+
+ private void seekStartPosition(Set<TopicPartition> partitions) {
+ ConsumerBuilder<byte[]> consumerBuilder =
+ createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
+ Set<String> seekedPartitions = new HashSet<>();
+
+ for (TopicPartition partition : partitions) {
+ String topicName = partition.getFullTopicName();
+ if (!seekedPartitions.contains(topicName)) {
Review comment:
```suggestion
if (seekedPartitions.add(topicName)) {
```
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/PulsarSourceBuilder.java
##########
@@ -473,12 +473,13 @@
// Since these implementation could be a lambda, make sure they are serializable.
checkState(isSerializable(startCursor), "StartCursor isn't serializable");
checkState(isSerializable(stopCursor), "StopCursor isn't serializable");
+ checkState(isSerializable(rangeGenerator), "RangeGenerator isn't serializable");
// Make the configuration unmodifiable.
- UnmodifiableConfiguration config = new UnmodifiableConfiguration(configuration);
+ UnmodifiableConfiguration immutableConfig = new UnmodifiableConfiguration(configuration);
return new PulsarSource<>(
- config,
+ immutableConfig,
Review comment:
unnecessary changes
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,44 @@ public void close() {
* @return Set of subscribed {@link TopicPartition}s
*/
private Set<TopicPartition> getSubscribedTopicPartitions() {
- return subscriber.getSubscribedTopicPartitions(
- pulsarAdmin, rangeGenerator, context.currentParallelism());
+ int parallelism = context.currentParallelism();
+ Set<TopicPartition> partitions =
+ subscriber.getSubscribedTopicPartitions(pulsarAdmin, rangeGenerator, parallelism);
+
+ // Seek start position for given partitions.
+ seekStartPosition(partitions);
+
+ return partitions;
+ }
+
+ private void seekStartPosition(Set<TopicPartition> partitions) {
+ ConsumerBuilder<byte[]> consumerBuilder =
+ createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
+ Set<String> seekedPartitions = new HashSet<>();
+
+ for (TopicPartition partition : partitions) {
+ String topicName = partition.getFullTopicName();
+ if (!seekedPartitions.contains(topicName)) {
+ try (Consumer<byte[]> consumer =
+ sneakyClient(() -> consumerBuilder.clone().topic(topicName).subscribe())) {
+ startCursor.seekPosition(
+ partition.getTopic(), partition.getPartitionId(), consumer);
+ } catch (PulsarClientException e) {
+ if (sourceConfiguration.getVerifyInitialOffsets() == FAIL_ON_MISMATCH) {
+ throw new IllegalArgumentException(e);
+ } else {
+ // WARN_ON_MISMATCH would just print this warning message.
+ // No need to print the stacktrace.
+ LOG.warn(
+ "Failed to set initial consuming position for partition {}",
+ partition,
+ e);
+ }
+ }
+
+ seekedPartitions.add(topicName);
Review comment:
```suggestion
```
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,44 @@ public void close() {
* @return Set of subscribed {@link TopicPartition}s
*/
private Set<TopicPartition> getSubscribedTopicPartitions() {
- return subscriber.getSubscribedTopicPartitions(
- pulsarAdmin, rangeGenerator, context.currentParallelism());
+ int parallelism = context.currentParallelism();
+ Set<TopicPartition> partitions =
+ subscriber.getSubscribedTopicPartitions(pulsarAdmin, rangeGenerator, parallelism);
+
+ // Seek start position for given partitions.
+ seekStartPosition(partitions);
+
+ return partitions;
+ }
+
+ private void seekStartPosition(Set<TopicPartition> partitions) {
+ ConsumerBuilder<byte[]> consumerBuilder =
+ createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
+ Set<String> seekedPartitions = new HashSet<>();
+
+ for (TopicPartition partition : partitions) {
+ String topicName = partition.getFullTopicName();
Review comment:
When do we actually have duplicate topicNames? Is it for sticky keys?
##########
File path: flink-connectors/flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/source/split/PulsarPartitionSplitTest.java
##########
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.flink.connector.pulsar.source.split;
-
-import org.apache.flink.connector.pulsar.source.enumerator.cursor.CursorPosition;
-import org.apache.flink.connector.pulsar.source.enumerator.cursor.StartCursor;
-import org.apache.flink.connector.pulsar.source.enumerator.topic.TopicPartition;
-
-import org.apache.pulsar.client.impl.MessageIdImpl;
-import org.junit.jupiter.api.Test;
-
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
-import static org.apache.flink.connector.pulsar.source.enumerator.cursor.StartCursor.defaultStartCursor;
-import static org.apache.flink.connector.pulsar.source.enumerator.cursor.StopCursor.defaultStopCursor;
-import static org.apache.flink.connector.pulsar.source.enumerator.topic.TopicRange.createFullRange;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-/** Unit tests for {@link PulsarPartitionSplit}. */
-class PulsarPartitionSplitTest {
-
- @Test
- void partitionSplitWouldHaveANewStartCursorWhenCheckpointing() {
Review comment:
Why did you remove this test?
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,44 @@ public void close() {
* @return Set of subscribed {@link TopicPartition}s
*/
private Set<TopicPartition> getSubscribedTopicPartitions() {
- return subscriber.getSubscribedTopicPartitions(
- pulsarAdmin, rangeGenerator, context.currentParallelism());
+ int parallelism = context.currentParallelism();
+ Set<TopicPartition> partitions =
+ subscriber.getSubscribedTopicPartitions(pulsarAdmin, rangeGenerator, parallelism);
+
+ // Seek start position for given partitions.
+ seekStartPosition(partitions);
+
+ return partitions;
+ }
+
+ private void seekStartPosition(Set<TopicPartition> partitions) {
+ ConsumerBuilder<byte[]> consumerBuilder =
+ createConsumerBuilder(pulsarClient, Schema.BYTES, configuration);
+ Set<String> seekedPartitions = new HashSet<>();
+
+ for (TopicPartition partition : partitions) {
+ String topicName = partition.getFullTopicName();
+ if (!seekedPartitions.contains(topicName)) {
+ try (Consumer<byte[]> consumer =
+ sneakyClient(() -> consumerBuilder.clone().topic(topicName).subscribe())) {
+ startCursor.seekPosition(
+ partition.getTopic(), partition.getPartitionId(), consumer);
+ } catch (PulsarClientException e) {
+ if (sourceConfiguration.getVerifyInitialOffsets() == FAIL_ON_MISMATCH) {
+ throw new IllegalArgumentException(e);
+ } else {
+ // WARN_ON_MISMATCH would just print this warning message.
+ // No need to print the stacktrace.
+ LOG.warn(
+ "Failed to set initial consuming position for partition {}",
+ partition,
+ e);
Review comment:
Get rid of `e` parameter? Or do we need the stacktrace?
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/split/PulsarOrderedPartitionSplitReader.java
##########
@@ -75,7 +78,30 @@ protected void finishedPollMessage(Message<byte[]> message) {
@Override
protected void startConsumer(PulsarPartitionSplit split, Consumer<byte[]> consumer) {
- initialStartPosition(split, consumer);
+ MessageId latestConsumedId = split.getLatestConsumedId();
+
+ // Reset the start position for ordered pulsar consumer.
+ if (latestConsumedId != null) {
+ StartCursor startCursor = StartCursor.fromMessageId(latestConsumedId, false);
+ TopicPartition partition = split.getPartition();
+
+ try {
+ startCursor.seekPosition(
+ partition.getTopic(), partition.getPartitionId(), consumer);
Review comment:
Why do we seek here? I thought the purpose was to only seek in enumerator?
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/split/PulsarUnorderedPartitionSplitReader.java
##########
@@ -137,16 +137,18 @@ protected void startConsumer(PulsarPartitionSplit split, Consumer<byte[]> consum
// Redeliver unacknowledged messages because of the message is out of order.
consumer.redeliverUnacknowledgedMessages();
- } else {
- initialStartPosition(split, consumer);
}
}
public PulsarPartitionSplitState snapshotState(long checkpointId) {
- TxnID txnID = PulsarTransactionUtils.getId(uncommittedTransaction);
- this.uncommittedTransaction = newTransaction();
PulsarPartitionSplitState state = new PulsarPartitionSplitState(registeredSplit);
- state.setUncommittedTransactionId(txnID);
+
+ // Avoiding NP problem when Pulsar don't get the message before Flink checkpoint.
+ if (uncommittedTransaction != null) {
Review comment:
Please add `@Nullable` to `uncommittedTransaction` field declaration that helps IDE to warn us for such issues.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
}, {
"hash" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "87e3f1eba6e972cf4fde5e65e95d45eeffdee013",
"triggerType" : "PUSH"
}, {
"hash" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "6c4aa79c4cc1d785bc46787bf730c7dc74f01f78",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ed5fc47b3d324ca63da8ff25b93e8057d5ba8953 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406)
* 87e3f1eba6e972cf4fde5e65e95d45eeffdee013 UNKNOWN
* 6c4aa79c4cc1d785bc46787bf730c7dc74f01f78 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ed5fc47b3d324ca63da8ff25b93e8057d5ba8953 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=23406)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #17119:
URL: https://github.com/apache/flink/pull/17119#issuecomment-911597744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "ed5fc47b3d324ca63da8ff25b93e8057d5ba8953",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ed5fc47b3d324ca63da8ff25b93e8057d5ba8953 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] AHeise commented on a change in pull request #17119: [FLINK-23848][connector/pulsar] Fix the consumer not found error in test.
Posted by GitBox <gi...@apache.org>.
AHeise commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r701844841
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/split/PulsarOrderedPartitionSplitReader.java
##########
@@ -75,7 +78,30 @@ protected void finishedPollMessage(Message<byte[]> message) {
@Override
protected void startConsumer(PulsarPartitionSplit split, Consumer<byte[]> consumer) {
- initialStartPosition(split, consumer);
+ MessageId latestConsumedId = split.getLatestConsumedId();
+
+ // Reset the start position for ordered pulsar consumer.
+ if (latestConsumedId != null) {
+ StartCursor startCursor = StartCursor.fromMessageId(latestConsumedId, false);
+ TopicPartition partition = split.getPartition();
+
+ try {
+ startCursor.seekPosition(
+ partition.getTopic(), partition.getPartitionId(), consumer);
Review comment:
In case of restart, isn't `latestConsumedId` always `null`? I thought we would update the `startCursor` on checkpoint, such that it should be properly initialized in enumerator/reader right?
##########
File path: flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,42 @@ public void close() {
* @return Set of subscribed {@link TopicPartition}s
*/
private Set<TopicPartition> getSubscribedTopicPartitions() {
- return subscriber.getSubscribedTopicPartitions(
- pulsarAdmin, rangeGenerator, context.currentParallelism());
+ int parallelism = context.currentParallelism();
+ Set<TopicPartition> partitions =
+ subscriber.getSubscribedTopicPartitions(pulsarAdmin, rangeGenerator, parallelism);
+
+ // Seek start position for given partitions.
+ seekStartPosition(partitions);
Review comment:
I think this should only be called in `assignPendingPartitionSplits`. Now if you have discover enabled, it would actually seek too often.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org