Skip to content

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

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

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

Conversation

@rustatian

@rustatian rustatian commented May 29, 2026

Copy link
Copy Markdown
Member

Summary

Fix confirmed bugs, apply Go 1.26 idioms, and remove dead code across boltjobs and boltkv.

Applied fixes

R — Bugs fixed (5)

# Location Finding
1 boltkv/driver.go Get Decoded value as string while Set/MGet encode as []byte — silent data corruption on every Get; fixed to decode []byte
2 boltkv/driver.go startGCLoop clearMu.RLock() not deferred — leaked on any panic inside gc.Range; extracted gcRun() helper with defer clearMu.RUnlock()
3 boltjobs/listener.go delayedJobsListener continue after rollback advanced the cursor on a dead (rolled-back) transaction; replaced with break + txOk flag
4 boltjobs/listener.go rollback Duplicate slog key "error" dropped one value; renamed second key to "rollback_error"
5 boltjobs/driver.go create create() copied InQueue→PushBucket on restart without deleting source entries, causing duplicate processing after restart

M — Modern Go 1.26 idioms (3)

# Location Change
6 boltjobs/driver.go + item.go + listener.go *uint64 pointer atomics → atomic.Uint64 value fields in Driver and Options; updated attachDB signature
7 boltjobs/driver.go listeners.Add(^uint32(0)) decrement trick → listeners.Store(0) (counter is always 0 or 1)
8 boltjobs/listener.go bytes.Compareslices.Compare

S — Simplifications (1)

# Location Change
9 boltjobs/driver.go Removed dead cond *sync.Cond field (allocated in both constructors, never read)

Deps

go get -u all && go mod tidy in root and tests/; go work sync — no version changes (already up to date).

Fix high/med bugs across boltjobs and boltkv:
- boltkv/driver.go: Get decoded value as string instead of []byte (type mismatch with Set/MGet — silent data corruption)
- boltkv/driver.go: RLock in startGCLoop not deferred; extract gcRun to use defer for panic safety
- boltjobs/listener.go: delayedJobsListener cursor.Next() on rolled-back tx (dead tx); switch continue→break with txOk flag
- boltjobs/listener.go: duplicate slog key "error" in rollback log; rename second to "rollback_error"
- boltjobs/driver.go: create() copied InQueue→PushBucket on restart without deleting source entries (duplicates)

Modernize (Go 1.26 idioms):
- boltjobs: *uint64 active/delayed pointer atomics → atomic.Uint64 value fields in Driver and Options; update attachDB signature
- boltjobs/driver.go: listeners.Add(^uint32(0)) decrement trick → Store(0) (counter is always 0 or 1)
- boltjobs/listener.go: bytes.Compare → slices.Compare

Simplify:
- boltjobs/driver.go: remove dead cond *sync.Cond field (allocated, never read)
Copilot AI review requested due to automatic review settings May 29, 2026 12:25
@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 22 minutes and 32 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: d4b60afc-b3d8-4915-bf39-a0f830e52aa9

📥 Commits

Reviewing files that changed from the base of the PR and between c3d4cbe and 5fde268.

📒 Files selected for processing (4)
  • boltjobs/driver.go
  • boltjobs/item.go
  • boltjobs/listener.go
  • boltkv/driver.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 modernizes BoltDB-backed jobs and KV drivers while addressing several correctness issues in job recovery, delayed-job rollback handling, KV decoding, and GC lock cleanup.

Changes:

  • Updates job counters to value-style atomics and removes unused condition variable setup.
  • Fixes KV Get decoding to match stored []byte values and extracts GC work into a defer-protected helper.
  • Adjusts delayed-job rollback flow and restart recovery handling for in-flight jobs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
boltkv/driver.go Fixes Get value decoding and refactors GC loop locking into gcRun.
boltjobs/listener.go Updates atomic usage, delayed-job comparison, and rollback logging/control flow.
boltjobs/item.go Switches item counter references to atomic.Uint64.
boltjobs/driver.go Removes unused condition variable, updates atomic counter usage, and changes restart recovery cleanup.

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

Comment thread boltjobs/driver.go Outdated
Comment thread boltjobs/listener.go
…back

In create(), deleting the current bbolt cursor key mid-iteration shifts
the underlying inode slice so cursor.Next() skips the following entry.
Fix by collecting all InQueueBucket entries into a slice first, then
moving them to PushBucket in a separate pass.

In delayedJobsListener(), d.pq.Insert was called inside the transaction
loop before tx.Commit(), so a commit failure left items in the in-memory
priority queue even though the bbolt transaction was rolled back. Fix by
accumulating decoded items and inserting them only after a successful commit.
@rustatian rustatian self-assigned this Jun 3, 2026
@rustatian rustatian merged commit 49f0964 into master Jun 3, 2026
7 checks passed
@rustatian rustatian deleted the chore/cleanup-modernize-deps branch June 3, 2026 19:47
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