Skip to content

Commit

Permalink
chore: less verbose debug logs
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <[email protected]>
  • Loading branch information
rustatian committed Dec 9, 2023
1 parent fcd1771 commit 4c845c3
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 411 deletions.
18 changes: 11 additions & 7 deletions beanstalkjobs/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"go.uber.org/zap"
)

var errBeanstalkTimeout = stderr.New("beanstalk timeout")

type ConnPool struct {
sync.RWMutex

Expand Down Expand Up @@ -96,7 +98,7 @@ func (cp *ConnPool) Reserve(reserveTimeout time.Duration) (uint64, []byte, error
// errN contains both, err and internal checkAndRedial error
errN := cp.checkAndRedial(err)
if errN != nil {
return 0, nil, errors.Errorf("err: %s\nerr redial: %s", err, errN)
return 0, nil, stderr.Join(err, errN)
}

// retry Reserve only when we redialed
Expand All @@ -118,13 +120,13 @@ func (cp *ConnPool) Delete(_ context.Context, id uint64) error {
return errors.Errorf("err: %s\nerr redial: %s", err, errN)
}

// retry Delete only when we redialed
// retry, Delete only when we redialed
return cp.connTS.Load().Delete(id)
}
return nil
}

func (cp *ConnPool) Stats(context.Context) (map[string]string, error) {
func (cp *ConnPool) Stats(_ context.Context) (map[string]string, error) {
cp.RLock()
defer cp.RUnlock()

Expand Down Expand Up @@ -206,7 +208,8 @@ func (cp *ConnPool) checkAndRedial(err error) error {
var bErr *net.OpError

if stderr.As(err, &et) {
if stderr.As(et.Err, &bErr) {
switch {
case stderr.As(et.Err, &bErr):
cp.log.Debug("beanstalk connection error, redialing", zap.Error(et))
cp.RUnlock()
errR := cp.redial()
Expand All @@ -220,9 +223,7 @@ func (cp *ConnPool) checkAndRedial(err error) error {
cp.log.Debug("beanstalk redial was successful")
// if redial was successful -> continue listening
return nil
}

if et.Err.Error() == EOF {
case et.Err.Error() == EOF:
cp.log.Debug("beanstalk connection error, redialing", zap.Error(et.Err))
// if error is related to the broken connection - redial
cp.RUnlock()
Expand All @@ -237,6 +238,9 @@ func (cp *ConnPool) checkAndRedial(err error) error {
cp.log.Debug("beanstalk redial was successful")
// if redial was successful -> continue listening
return nil
case et.Op == "reserve-with-timeout" && (et.Err.Error() == "deadline soon" || et.Err.Error() == "timeout"):
cp.log.Debug("connection deadline reached, continue listening", zap.Error(et))
return errBeanstalkTimeout
}
}

Expand Down
2 changes: 1 addition & 1 deletion beanstalkjobs/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
type Item struct {
// Job contains pluginName of job broker (usually PHP class).
Job string `json:"job"`
// Ident is unique identifier of the job, should be provided from outside
// Ident is a unique identifier of the job, should be provided from outside
Ident string `json:"id"`
// Payload is string data (usually JSON) passed to Job broker.
Payload []byte `json:"payload"`
Expand Down
15 changes: 5 additions & 10 deletions beanstalkjobs/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
stderr "errors"

"github.com/beanstalkd/go-beanstalk"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
"go.uber.org/zap"
Expand All @@ -21,17 +20,13 @@ func (d *Driver) listen() {
default:
id, body, err := d.pool.Reserve(d.reserveTimeout)
if err != nil {
// error isn't wrapped
var errB beanstalk.ConnError
if stderr.As(err, &errB) {
if stderr.Is(errB.Err, beanstalk.ErrTimeout) {
d.log.Info("beanstalk reserve timeout", zap.Error(errB))
continue
}
// this is not an error, but just a wait timeout for the new job
if stderr.Is(err, errBeanstalkTimeout) {
continue
}

// in case of other error - continue
d.log.Warn("beanstalk reserve", zap.Error(err))
// in case of another error log and continue
d.log.Error("beanstalk listen", zap.Error(err))
continue
}

Expand Down
9 changes: 1 addition & 8 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
Expand Down Expand Up @@ -370,6 +368,7 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/mholt/acmez v1.2.0 h1:1hhLxSgY5FvH5HCnGUuwbKY2VQVo8IU7rxXKSnZ7F30=
github.com/mholt/acmez v1.2.0/go.mod h1:VT9YwH1xgNX1kmYY89gY8xPJC84BFAisjo8Egigt4kE=
github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE=
Expand Down Expand Up @@ -417,8 +416,6 @@ github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFu
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/sftp v1.13.1 h1:I2qBYMChEhIjOgazfJmV3/mZM256btk6wkCDRmW7JYs=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU=
github.com/rabbitmq/amqp091-go v1.8.1 h1:RejT1SBUim5doqcL6s7iN6SBmsQqyTgXb1xMlH0h1hA=
Expand Down Expand Up @@ -496,16 +493,12 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245 h1:K1Xf3bKttbF+koVGaX5xngRIZ5bVjbmPnaxE/dR08uY=
github.com/sagikazarmark/crypt v0.10.0 h1:96E1qrToLBU6fGzo+PRRz7KGOc9FkYFiPnR3/zf8Smg=
github.com/sagikazarmark/crypt v0.10.0/go.mod h1:gwTNHQVoOS3xp9Xvz5LLR+1AauC5M6880z5NWzdhOyQ=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/segmentio/encoding v0.3.6 h1:E6lVLyDPseWEulBmCmAKPanDd3jiyGDo5gMcugCRwZQ=
github.com/segmentio/encoding v0.3.6/go.mod h1:n0JeuIqEQrQoPDGsjo8UNd1iA0U8d8+oHAA4E3G3OxM=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI=
github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI=
github.com/temporalio/roadrunner-temporal/v4 v4.5.0-beta.1 h1:ydGSV1fPM05OWYIRvNQJvoVPzuaKeLk6SFP0bgWO5Tg=
github.com/temporalio/roadrunner-temporal/v4 v4.5.0-beta.1/go.mod h1:Qg9LuVZOEn5WYdZupCTK5SVLZsmdMVQuJkyH3tl2t4g=
github.com/twmb/franz-go v1.15.0 h1:bw5n1COKJzWpkCXG/kMtHrurcS9HSWV6e3If5CUdc+M=
Expand Down
2 changes: 1 addition & 1 deletion tests/configs/.rr-beanstalk-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ beanstalk:
timeout: 10s

logs:
level: info
level: debug
encoding: console
mode: development

Expand Down
42 changes: 21 additions & 21 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ require (
github.com/goccy/go-json v0.10.2
github.com/google/uuid v1.4.0
github.com/roadrunner-server/api/v4 v4.9.0
github.com/roadrunner-server/beanstalk/v4 v4.5.11
github.com/roadrunner-server/config/v4 v4.6.2
github.com/roadrunner-server/beanstalk/v4 v4.5.12
github.com/roadrunner-server/config/v4 v4.6.3
github.com/roadrunner-server/endure/v2 v2.4.3
github.com/roadrunner-server/goridge/v3 v3.8.1
github.com/roadrunner-server/informer/v4 v4.3.9
github.com/roadrunner-server/jobs/v4 v4.7.8
github.com/roadrunner-server/logger/v4 v4.2.9
github.com/roadrunner-server/otel/v4 v4.3.7
github.com/roadrunner-server/resetter/v4 v4.0.16
github.com/roadrunner-server/rpc/v4 v4.2.10
github.com/roadrunner-server/server/v4 v4.5.2
github.com/roadrunner-server/informer/v4 v4.3.10
github.com/roadrunner-server/jobs/v4 v4.7.9
github.com/roadrunner-server/logger/v4 v4.2.10
github.com/roadrunner-server/otel/v4 v4.3.8
github.com/roadrunner-server/resetter/v4 v4.0.17
github.com/roadrunner-server/rpc/v4 v4.2.11
github.com/roadrunner-server/server/v4 v4.5.3
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.26.0
)
Expand Down Expand Up @@ -66,18 +66,18 @@ require (
github.com/roadrunner-server/sdk/v4 v4.5.3 // indirect
github.com/roadrunner-server/tcplisten v1.4.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.17.0 // indirect
github.com/spf13/viper v1.18.1 // indirect
github.com/stretchr/objx v0.5.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
Expand All @@ -98,15 +98,15 @@ require (
go.temporal.io/sdk/contrib/opentelemetry v0.3.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.4.0 // indirect
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit 4c845c3

Please sign in to comment.