wolftankk edited a comment on issue #139: fatal error: concurrent map writes
URL: 
https://github.com/apache/rocketmq-client-go/issues/139#issuecomment-517638876
 
 
   it must add locker for CAS, so in 
   ```golang
   func (local *localFileOffsetStore) update(mq *primitive.MessageQueue, offset 
int64, increaseOnly bool) {
        rlog.Debugf("update offset: %s to %d", mq, offset)
        localOffset, exist := local.OffsetTable[mq.Topic]
        if !exist {
                localOffset = make(map[int]*queueOffset)
                local.OffsetTable[mq.Topic] = localOffset
        }
        q, exist := localOffset[mq.QueueId]
        if !exist {
                q = &queueOffset{
                        QueueID: mq.QueueId,
                        Broker:  mq.BrokerName,
                }
                localOffset[mq.QueueId] = q
        }
        if increaseOnly {
                if q.Offset < offset {
                        q.Offset = offset
                }
        } else {
                q.Offset = offset
        }
   }```
   
   it will add 
   
   ```golang
   func (local *localFileOffsetStore) update(mq *primitive.MessageQueue, offset 
int64, increaseOnly bool) {
           local.mutex.Lock()
        defer local.mutex.Unlock()
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to