riverqueue / river

Fast and reliable background jobs in Go
https://riverqueue.com
Mozilla Public License 2.0
3.43k stars 90 forks source link

In which case, it will cause the 'INFO Notifier: Listener closing'? #384

Closed RidaLiu closed 3 months ago

RidaLiu commented 3 months ago

Hi

I'm running the service locally successfully, but when I migrate to AWS, it reports the log like ' 2024/06/10 09:11:16 INFO Notifier: Listener connecting 2024/06/10 09:11:16 INFO Notifier: Listening on topic topic=river_leadership 2024/06/10 09:11:16 INFO Notifier: Listener closing'

the log doesn't show more details, so in which case it will report this kind of issue?

my code is below, but I don't think it's caused by this func.

func NewPostgresPool(c *conf.DataService, logger *zap.Logger) (*pgxpool.Pool, error) {
    dbc := c.Postgresql
    logTask := "CREATE_POSTGRES_POOL"
    // Replace special char
    encodedPassword := url.QueryEscape(dbc.Password)
    // river as the alternative schema
    connectionString := fmt.Sprintf(
        "postgres://%s:%s@%s/%s?search_path=%s",
        dbc.Username,
        encodedPassword,
        dbc.Dblink,
        dbc.DbName,
        "river",
    )
    ctxWithTimeout, cancel := context.WithTimeout(context.Background(), dbc.ConnectTimeout.AsDuration())
    defer cancel()
    dbPool, err := pgxpool.New(ctxWithTimeout, connectionString)
    if err != nil {
        logger.Error(logTask, zap.String(bl.ErrorKey, err.Error()), zap.String(bl.ExecStatus, bl.ExecStatusFail))
        return nil, perr.ErrorInternalDatabaseError("%s, err: %s", logTask, err.Error())
    }
    logger.Info(
        logTask,
        zap.Bool("IsPingTestSuccess", dbPool.Ping(ctxWithTimeout) == nil),
    )
    return dbPool, nil
}
brandur commented 3 months ago

Probably the most likely explanations are that the River client is stopping or there was a bad startup error somewhere. Are there no other non-notifier logs around the ones you pasted?

RidaLiu commented 3 months ago

Probably the most likely explanations are that the River client is stopping or there was a bad startup error somewhere. Are there no other non-notifier logs around the ones you pasted?

it seems that it's caused by the database issue? or the driver version issue ? '''"error":"error listening on topic \"river_leadership\": ERROR: could not access status of transaction 150929435 '''

bgentry commented 3 months ago

This seems pretty likely to be an issue with your Postgres installation and not related to River. Here's a thread from a few years ago where somebody reports running into a similar issue when using LISTEN.

One thing you could try is to use poll-only mode (see PollOnly on Config here).

Unfortunately I don't think there's anything we could do to help with this or fix it, so I'll close the issue here. Please let us know if you find any more info that suggests this is a problem with River!

RidaLiu commented 3 months ago

This seems pretty likely to be an issue with your Postgres installation and not related to River. Here's a thread from a few years ago where somebody reports running into a similar issue when using LISTEN.

One thing you could try is to use poll-only mode (see PollOnly on Config here).

Unfortunately I don't think there's anything we could do to help with this or fix it, so I'll close the issue here. Please let us know if you find any more info that suggests this is a problem with River!

Thanks, PollOnly is helpful, it's fixed.