Chickenzilla commented on a change in pull request #23:
URL: https://github.com/apache/pulsar-dotpulsar/pull/23#discussion_r449516395



##########
File path: src/DotPulsar/Internal/ProducerChannel.cs
##########
@@ -90,18 +90,16 @@ public Task<CommandSendReceipt> Send(MessageMetadata 
metadata, ReadOnlySequence<
 
                 if (autoAssignSequenceId)
                 {
-                    sendPackage.Command.SequenceId = _sequenceId.Current;
-                    sendPackage.Metadata.SequenceId = _sequenceId.Current;
+                    var newSequenceId = _sequenceId.FetchNext();
+                    sendPackage.Command.SequenceId = newSequenceId;
+                    sendPackage.Metadata.SequenceId = newSequenceId;
                 }
                 else
                     sendPackage.Command.SequenceId = 
sendPackage.Metadata.SequenceId;
 
                 var response = await _connection.Send(sendPackage, 
cancellationToken).ConfigureAwait(false);
                 response.Expect(BaseCommand.Type.SendReceipt);
 
-                if (autoAssignSequenceId)
-                    _sequenceId.Increment();

Review comment:
       If the connection is lost, does it matter if the sequence id is ruined?  
You aren't sending any more packets to that server anyhow (unless I'm wrong and 
you can reconnect and continue like nothing ever happened?).  Other scenarios 
are more tricky perhaps, but the gist of the issue is that now that you can 
have multiple threads in here at once, it's not safe to increment in that way, 
at that time (currently it seems to me multiple sends may have the same 
sequence id, which seems worse).




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

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


Reply via email to