Open BewareMyPower opened 2 years ago
Using an idempotent producer works. It looks like this bug is not related to Pulsar.
final var bootstrapServers = "localhost:9092";
final var topic = "my-topic-4";
final var props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
props.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true);
@Cleanup final var producer = new KafkaProducer<String, String>(props);
producer.send(new ProducerRecord<>(topic, 0, null, "hello"));
The stats is similar (no producer, only 1 pulsar.dedup
non-durable cursor), but the topic can be deleted.
$ ./bin/pulsar-admin topics partitioned-stats-internal my-topic-4
{
"metadata" : {
"partitions" : 1
},
"partitions" : {
"persistent://public/default/my-topic-4-partition-0" : {
"entriesAddedCounter" : 1,
"numberOfEntries" : 1,
"totalSize" : 51,
"currentLedgerEntries" : 1,
"currentLedgerSize" : 51,
"lastLedgerCreatedTimestamp" : "2022-07-06T16:35:10.711+08:00",
"waitingCursorsCount" : 0,
"pendingAddEntriesCount" : 0,
"lastConfirmedEntry" : "234:0",
"state" : "LedgerOpened",
"ledgers" : [ {
"ledgerId" : 234,
"entries" : 0,
"size" : 0,
"offloaded" : false,
"underReplicated" : false
} ],
"cursors" : {
"pulsar.dedup" : {
"markDeletePosition" : "234:-1",
"readPosition" : "234:0",
"waitingReadOp" : false,
"pendingReadOps" : 0,
"messagesConsumedCounter" : 0,
"cursorLedger" : 235,
"cursorLedgerLastEntry" : 0,
"individuallyDeletedMessages" : "[]",
"lastLedgerSwitchTimestamp" : "2022-07-06T16:35:10.724+08:00",
"state" : "Open",
"numberOfEntriesSinceFirstNotAckedMessage" : 1,
"totalNonContiguousDeletedMessagesRange" : 0,
"subscriptionHavePendingRead" : false,
"subscriptionHavePendingReplayRead" : false,
"properties" : { }
}
},
"schemaLedgers" : [ ],
"compactedLedger" : {
"ledgerId" : -1,
"entries" : -1,
"size" : -1,
"offloaded" : false,
"underReplicated" : false
}
}
}
}
$ ./bin/pulsar-admin topics delete-partitioned-topic my-topic-4
you could be delete topic with --force options when topics has connected producers or consumers.
Yeah, but this issue is more about why the topic cannot be deleted. It's okay to delete the topic with -f
option, but if there were some producers, the topic could be created automatically and might lead to some unexpected results.
BTW, the cause of this issue is that there's a InternalProducer
object, which extends the broker's Producer
class, is writing the transactional marker when the topic is deleted.
Thanks for your prompt reply and helpful suggestion,has any commits to fixed this issue up to now?
See https://github.com/streamnative/kop/pull/1388. Actually, the topic could be deleted after waiting for a while. Because at the time producer.commitTransaction()
returns, the related transaction marker might not be written. After the marker being written successfully, the topic could be deleted.
Describe the bug
To Reproduce
KoP configs:
First, create the partitioned topic via
pulsar-admin
:Then, run the following Kafka application:
Then, try to delete the topic:
Expected behavior The topic should be deleted.
Additional context
Here are the essential broker logs:
Here is the internal stats of
my-topic-5
: