Skip to content

Some probability exists that the pipeline only returns part of the results for certain commands. #2543

Closed as not planned
@xuanskyer

Description

@xuanskyer

The issue occurs when using the Pipeline method to retrieve multiple content caches in a batch manner from Redis version 7. Some probability exists that the pipeline only returns part of the results for certain commands.

Here is an example of code that demonstrates the issue:

// some codes...  
redisResults := make([]*redisv7.StringStringMapCmd, len(contentIds))  
	pipe := redisClient.Pipeline()  
	for i, id := range contentIds {  
		redisResults[i] = pipe.HGetAll(id)  
	}  
	if _, err := pipe.Exec(); err != nil {  
		logger.Log().Error("err", zap.Error(err), zap.Any("contentIds", contentIds))  
		return nil, nil, errors.New("err exec")  
	}

	metaList = make([]ContentMeta, 0, len(contentIds))  
	missIds = make([]string, 0, len(contentIds))  
	errList := make([]string, 0)  
	for idx, result := range redisResults {  
		if val, err := result.Result(); err == nil && len(val) > 0 {  
			metaList = append(metaList, val)  
		} else {  
			errStr := fmt.Sprintf("id: %d, len(val): %d, content_id: %s, result: %s ", idx, len(val), contentIds[idx], result.String())  
			if err != nil {  
				errStr += fmt.Sprintf("err: %s", err.Error())  
			}  
			errList = append(errList, errStr)  
			missIds = append(missIds, contentIds[idx])  
		}  
	}  
	if len(errList) > 0 {  
		logger.Log().Error("Pipeline_err: ", zap.Error(err), zap.Any("contentIds", contentIds), zap.Any("errList", errList))  
	}  

Looking at the code log above, it was found that sometimes the following issues occur:

For example, when contentIds are: ["123", "456", "789"] (these three corresponding Redis cache keys do indeed exist), sometimes only 2 or 1 results are returned.

What is the reason for this?

Is it possible that it was due to the timeout?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions