You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/08/25 03:18:25 UTC

[GitHub] [pulsar-client-go] wolfstudy opened a new pull request #598: Fix producer panic by oldProducers

wolfstudy opened a new pull request #598:
URL: https://github.com/apache/pulsar-client-go/pull/598


   Signed-off-by: xiaolongran <xi...@tencent.com>
   
   
   
   ### Motivation
   
   ```
   panic: runtime error: index out of range [1] with length 1
   
   goroutine 166288 [running]:
   github.com/apache/pulsar-client-go/pulsar.(*producer).internalCreatePartitionsProducers(0xc0070aa6e0, 0x0, 0x0)
           /Users/lzhuang/scfproj/scf_trigger_v2/vendor/github.com/apache/pulsar-client-go/pulsar/producer_impl.go:194 +0x785
   github.com/apache/pulsar-client-go/pulsar.(*producer).runBackgroundPartitionDiscovery.func1(0xc004167cd0, 0xc00559f5c0, 0xc006af6dc0, 0xc0070aa6e0)
           /Users/lzhuang/scfproj/scf_trigger_v2/vendor/github.com/apache/pulsar-client-go/pulsar/producer_impl.go:152 +0xce
   created by github.com/apache/pulsar-client-go/pulsar.(*producer).runBackgroundPartitionDiscovery
           /Users/lzhuang/scfproj/scf_trigger_v2/vendor/github.com/apache/pulsar-client-go/pulsar/producer_impl.go:144 +0xcd
   ```
   
   ### Modifications
   
   indexing may panic because of 'nil' slice(oldProducers)
   
   


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar-client-go] wolfstudy commented on a change in pull request #598: Fix producer panic by oldProducers

Posted by GitBox <gi...@apache.org>.
wolfstudy commented on a change in pull request #598:
URL: https://github.com/apache/pulsar-client-go/pull/598#discussion_r695371232



##########
File path: pulsar/producer_impl.go
##########
@@ -190,8 +190,10 @@ func (p *producer) internalCreatePartitionsProducers() error {
 	p.producers = make([]Producer, newNumPartitions)
 
 	// Copy over the existing consumer instances
-	for i := 0; i < oldNumPartitions; i++ {
-		p.producers[i] = oldProducers[i]
+	if oldProducers != nil {

Review comment:
       Cool, updated! PTAL again




-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar-client-go] wolfstudy merged pull request #598: Fix producer panic by oldProducers

Posted by GitBox <gi...@apache.org>.
wolfstudy merged pull request #598:
URL: https://github.com/apache/pulsar-client-go/pull/598


   


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar-client-go] wolfstudy commented on pull request #598: Fix producer panic by oldProducers

Posted by GitBox <gi...@apache.org>.
wolfstudy commented on pull request #598:
URL: https://github.com/apache/pulsar-client-go/pull/598#issuecomment-905218775


   In this pr, a check for partition scale down is added to avoid the occurrence of the panic:
   
   ```
   time="2021-08-24T21:18:27+08:00" level=info msg="[Changed number of partitions in topic]" new_partitions=1 old_partitions=20 topic="persistent://pulsar-ev297bm5n9j4/dogfood/1253970226_lam-1f67hbru"
   ```


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar-client-go] wolfstudy commented on pull request #598: [WIP]Fix producer panic by oldProducers

Posted by GitBox <gi...@apache.org>.
wolfstudy commented on pull request #598:
URL: https://github.com/apache/pulsar-client-go/pull/598#issuecomment-905216297


   ```
   ==================
   WARNING: DATA RACE
   Read at 0x00c00071a038 by goroutine 332:
     github.com/apache/pulsar-client-go/pulsar.(*producer).getPartition()
         /pulsar-client-go/pulsar/producer_impl.go:281 +0xd6
     github.com/apache/pulsar-client-go/pulsar.(*producer).Send()
         /pulsar-client-go/pulsar/producer_impl.go:269 +0x61
     github.com/apache/pulsar-client-go/pulsar.TestConsumerAddTopicPartitions()
         /pulsar-client-go/pulsar/consumer_test.go:1463 +0x915
     testing.tRunner()
         /usr/local/go/src/testing/testing.go:1050 +0x1eb
   
   Previous write at 0x00c00071a038 by goroutine 9:
     github.com/apache/pulsar-client-go/pulsar.(*producer).internalCreatePartitionsProducers()
         /pulsar-client-go/pulsar/producer_impl.go:179 +0x1e2
     github.com/apache/pulsar-client-go/pulsar.(*producer).runBackgroundPartitionDiscovery.func1()
         /pulsar-client-go/pulsar/producer_impl.go:153 +0xfa
   
   Goroutine 332 (running) created at:
     testing.(*T).Run()
         /usr/local/go/src/testing/testing.go:1095 +0x537
     testing.runTests.func1()
         /usr/local/go/src/testing/testing.go:1339 +0xa6
     testing.tRunner()
         /usr/local/go/src/testing/testing.go:1050 +0x1eb
     testing.runTests()
         /usr/local/go/src/testing/testing.go:1337 +0x594
     testing.(*M).Run()
         /usr/local/go/src/testing/testing.go:1252 +0x2ff
     main.main()
         _testmain.go:432 +0x337
   
   Goroutine 9 (running) created at:
     github.com/apache/pulsar-client-go/pulsar.(*producer).runBackgroundPartitionDiscovery()
         /pulsar-client-go/pulsar/producer_impl.go:145 +0x11b
     github.com/apache/pulsar-client-go/pulsar.newProducer()
         /pulsar-client-go/pulsar/producer_impl.go:133 +0x701
     github.com/apache/pulsar-client-go/pulsar.(*client).CreateProducer()
         /pulsar-client-go/pulsar/client_impl.go:150 +0xb4
     github.com/apache/pulsar-client-go/pulsar.TestConsumerAddTopicPartitions()
         /pulsar-client-go/pulsar/consumer_test.go:1433 +0x39a
     testing.tRunner()
         /usr/local/go/src/testing/testing.go:1050 +0x1eb
   ==================
   panic: runtime error: invalid memory address or nil pointer dereference
   [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xed0548]
   
   goroutine 4816 [running]:
   github.com/apache/pulsar-client-go/pulsar.(*partitionConsumer).getConsumerState(0x0, 0xc000000001)
   	/pulsar-client-go/pulsar/consumer_partition.go:338 +0x48
   github.com/apache/pulsar-client-go/pulsar.(*partitionConsumer).Close(0x0)
   	/pulsar-client-go/pulsar/consumer_partition.go:347 +0x55
   github.com/apache/pulsar-client-go/pulsar.(*consumer).Close.func1.1(0xc0000a4cc0, 0x0)
   	/pulsar-client-go/pulsar/consumer_impl.go:519 +0x88
   created by github.com/apache/pulsar-client-go/pulsar.(*consumer).Close.func1
   	/pulsar-client-go/pulsar/consumer_impl.go:517 +0x1b8
   ```


-- 
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: commits-unsubscribe@pulsar.apache.org

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



[GitHub] [pulsar-client-go] merlimat commented on a change in pull request #598: Fix producer panic by oldProducers

Posted by GitBox <gi...@apache.org>.
merlimat commented on a change in pull request #598:
URL: https://github.com/apache/pulsar-client-go/pull/598#discussion_r695367596



##########
File path: pulsar/producer_impl.go
##########
@@ -190,8 +190,10 @@ func (p *producer) internalCreatePartitionsProducers() error {
 	p.producers = make([]Producer, newNumPartitions)
 
 	// Copy over the existing consumer instances
-	for i := 0; i < oldNumPartitions; i++ {
-		p.producers[i] = oldProducers[i]
+	if oldProducers != nil {

Review comment:
       This could be moved few lines above, where there is already a block that checks for != nil




-- 
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: commits-unsubscribe@pulsar.apache.org

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