idempotency_lock 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88b6cc80e37f3db005c446a96005520945b141ef45f1ff4d90863975de52ed45
4
- data.tar.gz: 43adf42af7496edc68cf46590fc2d09d585214c44dcd57487d0c290161f4af72
3
+ metadata.gz: 4920afd8d5429063037ecb787cf54915a0837d01dcc0e347143117c92aa1e842
4
+ data.tar.gz: fb92062859dc7f2dad7ecc897c6f327ddf486376b1177f2adbee01b595853429
5
5
  SHA512:
6
- metadata.gz: 989d09faf1a493cf14ee9426c4ffa67275a761e5784072164a0b3e24f9f3202a0424308f9621cace94e2245707ae25d936b96349a8798dfd5bb2b38656529b7c
7
- data.tar.gz: '084463272e767a8579dde4848d1a386645119404d65c608ee5d2960940963e877dbeaa3ed4c481679e6d5e14811cdeabeee2427a906571e2db9ea1366baf7344'
6
+ metadata.gz: e81784700e7745eb981190b9aa53268c79f47ee1897ff20ea04669254e684abd1e012247d35de67b6af499539e4034651a9a28486e9c3494137e7749af22a80d
7
+ data.tar.gz: 32838477ada126fce6e6ff26f5a07e6b363d34a846314e46808917e90a934cb283a62d21bb0312c3a451cf2f3cff67e20dd31a5cd8f77f67a7df536fb2f92e5c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2025-12-06
4
+
5
+ ### Changed
6
+
7
+ - Use `updated_at` instead of `expires_at` for optimistic locking (more reliable
8
+ since it's system-managed and always moves forward)
9
+
3
10
  ## [0.1.2] - 2025-12-06
4
11
 
5
12
  ### Fixed
@@ -56,12 +56,12 @@ module IdempotencyLock
56
56
  return false if existing.nil?
57
57
  return false unless existing.expired?(now: now)
58
58
 
59
- # Optimistic locking: use the observed expires_at in the WHERE clause.
59
+ # Optimistic locking: use the observed updated_at in the WHERE clause.
60
60
  # This prevents a race where two processes both see an expired lock and
61
61
  # both try to claim it. Only one UPDATE will match; the other returns 0.
62
- # This is safer than `WHERE expires_at < now` which could allow a second
63
- # process to steal a lock if the first used a short TTL.
64
- updated = where(name: name, expires_at: existing.expires_at)
62
+ # We use updated_at rather than expires_at because it's system-managed
63
+ # and always moves forward, making it more reliable for concurrency control.
64
+ updated = where(name: name, updated_at: existing.updated_at)
65
65
  .update_all(expires_at: expires_at, executed_at: now, updated_at: now)
66
66
 
67
67
  updated.positive?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IdempotencyLock
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idempotency_lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nagro