Comments (2)
If this is from the same log I looked at, I think it is transient -- or at least, some more tokens were added successfully later in the log.
from zkapauthorizer.
A closer reading of the log reveals:
2022-09-19T10:19:17-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 16
2022-09-19T10:19:19-0700 [_zkapauthorizer.resource._VoucherCollection#info] Accepting a voucher (VVV) for redemption.
2022-09-19T10:19:19-0700 [_zkapauthorizer.controller.PaymentController#info] Starting redemption of b'VVV'[0..16] for 150000 tokens.
2022-09-19T10:19:19-0700 [_zkapauthorizer.controller.PaymentController#info] Generating random tokens for a voucher (b'VVV').
2022-09-19T10:19:19-0700 [_zkapauthorizer.model.VoucherStore#info] Persisting 9375 random tokens for a voucher (VVV[0]).
2022-09-19T10:19:19-0700 [_zkapauthorizer.controller.PaymentController#info] Redeeming random tokens for a voucher (Voucher(number=b'VVV', expected_tokens=150000, created=datetime.datetime(2022, 9, 19, 17, 19, 19, 728643, tzinfo=+0:00:00 UTC), state=Pending(counter=0))).
2022-09-19T10:19:21-0700 [twisted.python.log#info] web: 127.0.0.1 PUT /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 -
2022-09-19T10:19:21-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 255
2022-09-19T10:19:21-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher/VVV 200 239
2022-09-19T10:19:21-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 255
2022-09-19T10:19:23-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 255
2022-09-19T10:19:24-0700 [twisted.web.client._HTTP11ClientFactory#info] Starting factory _HTTP11ClientFactory(<function HTTPConnectionPool._newConnection.<locals>.quiescentCallback at 0x00000243CD6EAA70>, <twisted.internet.endpoints._WrapperEndpoint object at 0x00000243CDD16C80>)
2022-09-19T10:19:25-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 255
2022-09-19T10:19:27-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 255
2022-09-19T10:19:29-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 255
2022-09-19T10:19:31-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 255
2022-09-19T10:19:33-0700 [twisted.python.log#info] web: 127.0.0.1 GET /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 255
2022-09-19T10:19:34-0700 [_zkapauthorizer.resource._VoucherCollection#info] Accepting a voucher (VVV) for redemption.
2022-09-19T10:19:34-0700 [_zkapauthorizer.controller.PaymentController#info] Starting redemption of b'VVV'[0..16] for 150000 tokens.
2022-09-19T10:19:34-0700 [_zkapauthorizer.model.VoucherStore#info] Loaded 9375 random tokens for a voucher (VVV[0]).
2022-09-19T10:19:34-0700 [_zkapauthorizer.controller.PaymentController#info] Redeeming random tokens for a voucher (Voucher(number=b'VVV', expected_tokens=150000, created=datetime.datetime(2022, 9, 19, 17, 19, 19, 728643, tzinfo=+0:00:00 UTC), state=Pending(counter=0))).
2022-09-19T10:19:35-0700 [twisted.python.log#info] web: 127.0.0.1 PUT /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 -
In particular, notice two instances of:
PUT /storage-plugins/privatestorageio-zkapauthz-v2/voucher 200 -
and two instances of:
Accepting a voucher (VVV) for redemption.
It seems the same voucher was loaded into the node twice. This should be idempotent, I guess, to allow client retries in the face of errors. And it is ... kind of. The two vouchers will share the same set of tokens. However, PaymentController
will try concurrent redemptions of those same tokens, too, and whichever of those processes loses the race will try to insert duplicate signed tokens into the database and provoke this UNIQUE constraint failure. PaymentController.redeem
probably needs to notice if a voucher is already redeeming.
There's even some logic for that already too. But PaymentController.redeem
jumps over it and goes straight to the database instead, woops.
from zkapauthorizer.
Related Issues (20)
- There is no way to retry a recovery attempt if downloading the replica fails
- /recover endpoint should be synchronous HOT 6
- StatefulRecoverer doesn't report enough error context
- Download and apply appropriate event stream objects during recovery
- Method for getting `recovery-capability` is missing
- Some tests in `test_client_resource.py` run asynchronous operations without waiting for them to complete
- Pass `mypy --strict` without `cast`, `type: ignore`, or features disabled in the configuration file
- Use APIs from tahoe-capabilities instead of `str` and APIs from Tahoe-LAFS for work on capabilities
- Have automated end-to-end testing of the replication/recovery system HOT 1
- Storage-time not fully redeeming to ~50GBs-months on a new voucher HOT 4
- RuntimeWarning: coroutine 'ZKAPAuthorizerStorageClient.slot_readv' was never awaited
- Some Eliot logging handles coroutines incorrectly
- There's no logging of activity around the recovery system
- tahoe-lafs 1.18.0 HOT 1
- CLI tool to facilitate populating ZKAPs
- unit-test failure on main
- The coverage collection/reporting job is failing on CI
- PriceCalculator is incorrect
- Bump the Tahoe-LAFS "dev" input
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zkapauthorizer.