Skip to content

Handling Panic in ctx.Lookup Caused by ctx.Fail in Goka Library #467

Description

@kevin-you2

Hello,

I’m encountering an issue with the Goka library where a panic occurs when using ctx.Lookup, which leads to the processor shutting down. The panic seems to be triggered by calls to ctx.Fail within the Lookup method. Here is the relevant code snippet from the Goka library:

func (ctx *cbContext) Lookup(topic Table, key string) interface{} {
    if ctx.views == nil {
        ctx.Fail(fmt.Errorf("topic %s not subscribed", topic))
    }
    v, ok := ctx.views[string(topic)]
    if !ok {
        ctx.Fail(fmt.Errorf("topic %s not subscribed", topic))
    }
    val, err := v.Get(key)
    if err != nil {
        ctx.Fail(fmt.Errorf("error getting key %s of table %s: %v", key, topic, err))
    }
    return val
}

When ctx.Fail is called, it results in a panic with the following error message:

error processing message (partition=0): panic in callback: error getting key 867604054647616 of table bicycle.avro: no partitions found

I understand that ctx.Fail is intended to initiate an immediate shutdown of the processor to maintain data integrity, and the documentation advises against recovering from this panic to avoid potential deadlocks.

However, in my application, I need to handle this exception gracefully without causing the entire processor to shut down. Is there a recommended way to handle errors within ctx.Lookup to prevent the panic from occurring? Alternatively, is there a way to catch this panic safely without risking a deadlock, so that I can log the error and continue processing?

Any guidance or suggestions on how to handle this situation would be greatly appreciated.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions