Goroutine 导致 EKS Pod 中出现分段错误

问题描述 投票:0回答:0
func (l *LS) GetRCDetails(ctx *common.Context, rcRequest vm.RCRequest) (vm.RCResponseData, base.VError) {
    defer common.StartSegment(ctx, "GetRCDetails").End()
    var rcResponse vm.RCResponse
    filter := bson.M{"reg_no": rcRequest.RCNumber}

    err := l.Mongo.Client.Collection(RCDataCollection).FindOne(ctx.Ctx, filter).Decode(&rcResponse.Data)
    ctx.Logger.Infof("error in decode :: %v", err)
    //to update existing vehicle data for additional fields
    if err == nil && rcResponse.Data.RegNo != "" && rcResponse.Data.Engine != "" {
        return rcResponse.Data, nil
    }
    ctx.Logger.Infof("Calling Notification service to get RC for RegNo:%s", rcRequest.RCNumber)
    _, rcResponse, err = l.notificationService.GetRCResponse(ctx, rcRequest)
    ctx.Logger.Infof("Received RC response from Notification service for RegNo:%s", rcRequest.RCNumber)
    if err != nil || rcResponse.Message != "" {
        verror := base.NewVahakError(http.StatusBadRequest, errors.New(rcResponse.Message)).DoNotSentryInstance()
        return rcResponse.Data, verror
    }
    rcResponse.Data.CreatedAt = time.Now().UTC()
    rcResponse.Data.UpdatedAt = time.Now().UTC()
    l.Mongo.Save(ctx, RCDataCollection, rcResponse.Data)
    return rcResponse.Data, nil

}

l.Mongo.Client.Collection(RCDataCollection).FindOne(ctx.Ctx, filter).解码(&rcResponse.Data) 上面这行是我的函数的一部分,当我在 EKS 的 pod 中运行 goroutine 时,它会导致分段错误,但是当我在 goroutine 外部调用它时,相同的函数运行正常。

注意:我尝试打印所有东西,但上面代码中使用的变量都不是零。 但我仍然收到错误消息

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13905b6]

但是当我在 goroutine 之外单独调用时,这个错误不会出现。

go routine 可能会出现什么问题?

go nullpointerexception segmentation-fault amazon-eks goroutine
© www.soinside.com 2019 - 2024. All rights reserved.