You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/12/14 12:21:00 UTC

[GitHub] [kafka] dengziming opened a new pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

dengziming opened a new pull request #11603:
URL: https://github.com/apache/kafka/pull/11603


   *More detailed description of your change*
   We store producer IDs in broker snapshots in #11527, I think we should also inspect it using MetadataShell.
   
   *Summary of testing strategy (including rationale)*
   I tested this locally:
   ```
   [ Kafka Metadata Shell ]
   >> cat /producerIds/broker
   1
   >> cat /producerIds/blockEnd
   1000
   >> 
   ```
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
hachikuji commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r804172617



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,16 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode producerIdNode = data.root.mkdirs("lastProducerIdBlock");
+                producerIdNode.create("assignedBrokerId").setContents(record.brokerId() + "");
+                producerIdNode.create("assignedBrokerEpoch").setContents(record.brokerEpoch() + "");
+                producerIdNode.create("blockStart")

Review comment:
       FYI: I opened #11747 to hopefully make the naming a little clearer.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
hachikuji commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r804998909



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,16 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode lastBlockNode = data.root.mkdirs("lastProducerIdBlock");

Review comment:
       I don't feel too strongly, but it seems a little odd to have the next and last blocks at the same level with different fields. How about this instead?
   
   - `/producerIds/nextBlockStartId`
   - `/producerIds/lastBlockAssignedBrokerId`
   - `/producerIds/lastBlockAssignedBrokerEpoch`
   
   Basically a more literal translation of the `ProducerIdsRecord`.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dengziming commented on pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
dengziming commented on pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#issuecomment-1000315005


   This change makes the MetadataShell generate the same output as what we get from zookeeper path "/latest_producer_id_block" added in #10504. ping @mumrah to have a look.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] mumrah commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
mumrah commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r804057789



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,16 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode producerIdNode = data.root.mkdirs("lastProducerIdBlock");
+                producerIdNode.create("assignedBrokerId").setContents(record.brokerId() + "");
+                producerIdNode.create("assignedBrokerEpoch").setContents(record.brokerEpoch() + "");
+                producerIdNode.create("blockStart")

Review comment:
       I agree we should avoid considering the block size here. From a metadata log perspective, the only way to know the block size is to replay the records. However, when handling a snapshot, you lose the ability to see what the block sizes were since everything has been collapsed into a single ProducerIdsRecord.
   
   We should expose this as a single value like "nextProducerIdBlockStart" or something. 




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
hachikuji commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r804998909



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,16 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode lastBlockNode = data.root.mkdirs("lastProducerIdBlock");

Review comment:
       I don't feel too strongly, but it seems a little odd to have the next and last blocks at the same level with different fields. How about this instead?
   
   - `/producerIds/nextBlockStartId`
   - `/producerIds/lastBlockBrokerId`
   - `/producerIds/lastBlockBrokerEpoch`
   
   Basically a more literal translation of the `ProducerIdsRecord`.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dengziming commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
dengziming commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r803264649



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,15 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode producerIdNode = data.root.mkdirs("producerIds");
+                producerIdNode.create("broker").setContents(record.brokerId() + "");

Review comment:
       Thank you for these suggestions, I think assignedBrokerId and assignedBrokerEpoch are enough since we don't use JSON format when parsing other metadata records.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dengziming commented on pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
dengziming commented on pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#issuecomment-993487546


   Hi, @cmccabe , this is a minor improvement similar to your PR #11527. PTAL.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji merged pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
hachikuji merged pull request #11603:
URL: https://github.com/apache/kafka/pull/11603


   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
hachikuji commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r803244663



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,15 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode producerIdNode = data.root.mkdirs("producerIds");
+                producerIdNode.create("broker").setContents(record.brokerId() + "");

Review comment:
       Maybe `assignedBrokerId`? As in, this was the brokerId that the block was assigned to. Also, perhaps we may as well add `assignedBrokerEpoch` as well? I guess we could even do it like `/lastProducerBlock/assignedBroker/{id,epoch}`, but maybe that's overkill.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
hachikuji commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r803244663



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,15 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode producerIdNode = data.root.mkdirs("producerIds");
+                producerIdNode.create("broker").setContents(record.brokerId() + "");

Review comment:
       Maybe `assignedBrokerId`? As in, this was the brokerId that the block was assigned to. Also, perhaps we may as well add `assignedBrokerEpoch` as well? I guess we could even do it like `/lastProducerBlock/assignedBroker/{id,epoch}`

##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,15 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode producerIdNode = data.root.mkdirs("producerIds");

Review comment:
       How about `lastProducerIdBlock`?




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dengziming commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
dengziming commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r804576005



##########
File path: shell/src/test/java/org/apache/kafka/shell/MetadataNodeManagerTest.java
##########
@@ -290,4 +293,47 @@ public void testClientQuotaRecord() {
             metadataNodeManager.getData().root().directory("client-quotas",
                 "user", "<default>").file("producer_byte_rate").contents());
     }
+
+    @Test
+    public void testProducerIdsRecord() {
+        // generate a producerId record
+        ProducerIdsRecord record1 = new ProducerIdsRecord()
+            .setBrokerId(0)
+            .setBrokerEpoch(1)
+            .setProducerIdsEnd(10000);
+        metadataNodeManager.handleMessage(record1);
+
+        assertEquals(
+            "0",
+            metadataNodeManager.getData().root().directory("lastProducerIdBlock").file("assignedBrokerId").contents());
+        assertEquals(
+            "1",
+            metadataNodeManager.getData().root().directory("lastProducerIdBlock").file("assignedBrokerEpoch").contents());
+        assertEquals(
+            10000 - ProducerIdsBlock.PRODUCER_ID_BLOCK_SIZE + "",
+            metadataNodeManager.getData().root().directory("lastProducerIdBlock").file("blockStart").contents());
+        assertEquals(
+            "9999",
+            metadataNodeManager.getData().root().directory("lastProducerIdBlock").file("blockEnd").contents());
+
+        // generate another brokerId

Review comment:
       Done, thanks.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dengziming commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
dengziming commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r804599430



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,16 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode producerIdNode = data.root.mkdirs("lastProducerIdBlock");
+                producerIdNode.create("assignedBrokerId").setContents(record.brokerId() + "");
+                producerIdNode.create("assignedBrokerEpoch").setContents(record.brokerEpoch() + "");
+                producerIdNode.create("blockStart")

Review comment:
       I split the `ProducerIdsRecord` into `lastProducerIdBlock` and `nextProducerIdBlock`. the former contains `assignedBrokerId` and `assignedBrokerEpoch`, the latter contains `firstProducerId`, this is more clear.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
hachikuji commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r804018735



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,16 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode producerIdNode = data.root.mkdirs("lastProducerIdBlock");
+                producerIdNode.create("assignedBrokerId").setContents(record.brokerId() + "");
+                producerIdNode.create("assignedBrokerEpoch").setContents(record.brokerEpoch() + "");
+                producerIdNode.create("blockStart")

Review comment:
       @dengziming I was looking at [KIP-730](https://cwiki.apache.org/confluence/display/KAFKA/KIP-730%3A+Producer+ID+generation+in+KRaft+mode). It is true that we currently hard-code the block length, but the `AllocateProducerIds` response reserves some flexibility for a dynamic block length (i.e. the block length is returned in the response). I wonder if it would be better not to depend on the hard-coded block size. Maybe we could make this `/producerIds/nextBlockStartId` or something like that.
   
   @mumrah What do you think?




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji merged pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
hachikuji merged pull request #11603:
URL: https://github.com/apache/kafka/pull/11603


   


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] mimaison commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
mimaison commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r803938280



##########
File path: shell/src/test/java/org/apache/kafka/shell/MetadataNodeManagerTest.java
##########
@@ -290,4 +293,47 @@ public void testClientQuotaRecord() {
             metadataNodeManager.getData().root().directory("client-quotas",
                 "user", "<default>").file("producer_byte_rate").contents());
     }
+
+    @Test
+    public void testProducerIdsRecord() {
+        // generate a producerId record
+        ProducerIdsRecord record1 = new ProducerIdsRecord()
+            .setBrokerId(0)
+            .setBrokerEpoch(1)
+            .setProducerIdsEnd(10000);
+        metadataNodeManager.handleMessage(record1);
+
+        assertEquals(
+            "0",
+            metadataNodeManager.getData().root().directory("lastProducerIdBlock").file("assignedBrokerId").contents());
+        assertEquals(
+            "1",
+            metadataNodeManager.getData().root().directory("lastProducerIdBlock").file("assignedBrokerEpoch").contents());
+        assertEquals(
+            10000 - ProducerIdsBlock.PRODUCER_ID_BLOCK_SIZE + "",
+            metadataNodeManager.getData().root().directory("lastProducerIdBlock").file("blockStart").contents());
+        assertEquals(
+            "9999",
+            metadataNodeManager.getData().root().directory("lastProducerIdBlock").file("blockEnd").contents());
+
+        // generate another brokerId

Review comment:
       nit: `brokerId` -> `producerId record`




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dengziming commented on a change in pull request #11603: MINOR: MetadataShell should handle ProducerIdsRecord

Posted by GitBox <gi...@apache.org>.
dengziming commented on a change in pull request #11603:
URL: https://github.com/apache/kafka/pull/11603#discussion_r805087020



##########
File path: shell/src/main/java/org/apache/kafka/shell/MetadataNodeManager.java
##########
@@ -318,6 +320,16 @@ private void handleCommitImpl(MetadataRecordType type, ApiMessage message)
                     node.create(record.key()).setContents(record.value() + "");
                 break;
             }
+            case PRODUCER_IDS_RECORD: {
+                ProducerIdsRecord record = (ProducerIdsRecord) message;
+                DirectoryNode lastBlockNode = data.root.mkdirs("lastProducerIdBlock");

Review comment:
       Yeah, better naming, done.




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org