You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/08/02 09:52:26 UTC

[GitHub] [rocketmq-client-go] wolftankk edited a comment on issue #139: fatal error: concurrent map writes

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 
   
   ```
   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:
users@infra.apache.org


With regards,
Apache Git Services