Skip to content

chore: simplify, modernize (Go 1.26), update deps#202

Merged
rustatian merged 2 commits into
masterfrom
chore/cleanup-modernize-deps
Jun 3, 2026
Merged

chore: simplify, modernize (Go 1.26), update deps#202
rustatian merged 2 commits into
masterfrom
chore/cleanup-modernize-deps

Conversation

@rustatian

@rustatian rustatian commented May 29, 2026

Copy link
Copy Markdown
Member

Applied fixes

R (bugs) — 7 applied

  • connection.go: close first conn when second DialTimeout fails in NewConnPool — fixes TCP leak (High)
  • connection.go: close connT when second DialTimeout fails in redial() — fixes TCP leak (High)
  • connection.go: close old connections when Swapping on redial — fixes conn leak on every reconnect (Med)
  • listen.go: skip pq.Insert after AutoAck delete — fixes double-processing of auto-acked jobs (Med)
  • driver.go: increment listeners before go d.listen in Resume — fixes race where concurrent Stop misses stopCh (Med)
  • driver.go: remove dead reconnectCh field (allocated, never read/written) (Med)
  • connection.go: errors.Is(et.Err, io.EOF) instead of et.Err.Error() == "EOF" (Low)

M (modern Go) — 2 applied

  • driver.go: atomic.Uint32atomic.Int32 for listeners; Add(^uint32(0))Add(-1) (Low)
  • config.go: time.Second * 1time.Second (Low)

S (simplify) — 5 applied

  • driver.go: remove dead addr / network fields (Low)
  • driver.go: new(bytes.Buffer)var bb bytes.Buffer (stack allocation) (Low)
  • driver.go: inline trivial ready() helper (Low)
  • driver.go: remove per-construction otel.SetTextMapPropagator global side-effect (Low)
  • item.go: bytes.NewBuffer(data)bytes.NewReader(data) (zero-copy read) (Low)
  • connection.go: use stderr.Join for multi-error returns; defer Unlock() in redial() (Low)

- connection.go: close first conn on second-dial failure in NewConnPool
  and redial(); close old connections on Swap (prevent conn leaks);
  use defer Unlock() in redial(); replace string EOF comparison with
  errors.Is(et.Err, io.EOF); use stderr.Join for multi-error returns
- driver.go: increment listeners before launching goroutine in Resume
  so concurrent Stop cannot miss the stopCh signal; remove dead
  reconnectCh, addr and network fields; switch listeners from
  atomic.Uint32 to atomic.Int32 and use Add(-1) instead of the
  Add(^uint32(0)) trick; inline ready() helper; use var bb bytes.Buffer
  (stack) instead of new(bytes.Buffer); remove per-construction
  otel.SetTextMapPropagator global side-effect
- listen.go: skip pq.Insert after AutoAck delete to prevent
  double-processing
- item.go: use bytes.NewReader (zero-copy) instead of bytes.NewBuffer
- config.go: time.Second * 1 → time.Second
Copilot AI review requested due to automatic review settings May 29, 2026 12:23
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@rustatian, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 16 minutes and 20 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4dcb1b0b-ca60-4e79-83c8-baf956b4ec75

📥 Commits

Reviewing files that changed from the base of the PR and between f1f3669 and ec4c3c3.

📒 Files selected for processing (4)
  • beanstalkjobs/config.go
  • beanstalkjobs/connection.go
  • beanstalkjobs/driver.go
  • beanstalkjobs/item.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/cleanup-modernize-deps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a chore-style cleanup of the beanstalk jobs driver: it bumps the module toolchain to Go 1.26, fixes several latent bugs (TCP/conn leaks in NewConnPool and redial, AutoAck double-processing, a Resume/Stop race, and EOF detection via string match), removes dead fields/helpers, and applies small modernizations (atomic.Int32, stack-allocated bytes.Buffer, bytes.NewReader, errors.Join, defer Unlock).

Changes:

  • Close leaked beanstalk connections in NewConnPool second-dial failure path and in redial's failure / swap paths; use errors.Is(..., io.EOF) instead of string compare.
  • Skip pq.Insert after AutoAck delete in the listener (avoids double-processing) and reorder Resume to increment listeners before launching the goroutine.
  • Cleanups: drop dead addr/network/reconnectCh fields and ready() helper, switch listeners to atomic.Int32, drop global otel.SetTextMapPropagator side-effect, replace bytes.NewBuffer with bytes.NewReader for decode, new(bytes.Buffer)var bb bytes.Buffer, time.Second * 1time.Second.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
beanstalkjobs/connection.go Fix conn leaks on dial failures, close old conns on Swap, use errors.Is(io.EOF), errors.Join, defer Unlock.
beanstalkjobs/driver.go Remove dead fields/helper, switch to atomic.Int32, reorder Resume increment, drop global propagator side-effect, stack-allocate encode buffer.
beanstalkjobs/listen.go After AutoAck delete, end span and continue to avoid inserting the already-acked job into the priority queue.
beanstalkjobs/item.go Use bytes.NewReader instead of bytes.NewBuffer for gob decode.
beanstalkjobs/config.go Simplify time.Second * 1 to time.Second.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The previous change added a continue after the AutoAck delete branch,
which skipped d.pq.Insert(item). AutoAck means acknowledge/delete the
job on the broker immediately (so it is not redelivered), but the job
must still be handed to a worker via the priority queue. Dropping the
insert silently discarded every auto-ack job.

Restore the fall-through to match the canonical AMQP and SQS drivers,
where AutoAck acks the message and then still inserts it into the PQ.
@rustatian rustatian self-assigned this Jun 3, 2026
@rustatian rustatian merged commit ec3b7d6 into master Jun 3, 2026
8 checks passed
@rustatian rustatian deleted the chore/cleanup-modernize-deps branch June 3, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants