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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/idempotency_lock/lock.rb +4 -4
- data/lib/idempotency_lock/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4920afd8d5429063037ecb787cf54915a0837d01dcc0e347143117c92aa1e842
|
|
4
|
+
data.tar.gz: fb92062859dc7f2dad7ecc897c6f327ddf486376b1177f2adbee01b595853429
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e81784700e7745eb981190b9aa53268c79f47ee1897ff20ea04669254e684abd1e012247d35de67b6af499539e4034651a9a28486e9c3494137e7749af22a80d
|
|
7
|
+
data.tar.gz: 32838477ada126fce6e6ff26f5a07e6b363d34a846314e46808917e90a934cb283a62d21bb0312c3a451cf2f3cff67e20dd31a5cd8f77f67a7df536fb2f92e5c
|
data/CHANGELOG.md
CHANGED
|
@@ -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
|
|
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
|
-
#
|
|
63
|
-
#
|
|
64
|
-
updated = where(name: name,
|
|
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?
|