storj/satellite/accounting
Ivan Fraixedes f626cd1868 satellite/accounting: Correctly cache project bandwidth
Satellite caches the project bandwidth in Redis when it doesn't have it
because was not set or the key expired, however, it doesn't perform the
check and set if not exists in a transaction. It also uses the increase
function which increases the value if it exists otherwise it sets it.

This provokes that multiple concurrent request to the same project may
increase the total project by multiples of the bandwidth usage
registered in the database rather than setting it because they may check
if the key exists before any other has executed the increase and then
the first one executing it will set the value but the others will
increased causing that Redis has a wrong bandwidth usage value which is
N magnitude of the real one and making the satellite to deny the
downloading if it surpasses the project limit.

This commit changes the "update"" project bandwidth usage by an "insert"
but using a Redis function that only sets the value if the key doesn't
exists for solving the increase issue but also not overriding the value
due to may contain updates of other downloading requests which aren't
already registered in the DB.

Change-Id: I33e2fe462930b2fdb4061fc94002bd3544476f94
2022-06-21 08:31:41 +00:00
..
live satellite/accounting: Correctly cache project bandwidth 2022-06-21 08:31:41 +00:00
nodetally satellite: use more optimal monkit call for loop observers methods 2022-05-20 11:03:41 +00:00
projectbwcleanup satellite/accounting: fix as of system interval value for some tests 2021-06-29 10:16:48 +00:00
rollup satellite/accounting: don't use testplanet in rollup_test if not necessary 2022-06-09 13:11:45 +00:00
rolluparchive satellites/orders: populate egress_dead in project_bandwidth_daily_rollups 2021-10-06 16:54:49 +00:00
tally satellite/accounting: add metrics for total pending objects 2022-06-06 12:04:46 +00:00
billing_test.go satellite: use segment count for billing 2021-10-27 19:21:50 +00:00
bucketstats.go satellite/accounting: add metrics for total pending objects 2022-06-06 12:04:46 +00:00
bucketusage.go satellite/accounting/tally: use objects iterator instead metaloop 2021-07-20 15:52:18 +00:00
common.go all: fix error naming 2021-04-29 15:38:21 +03:00
db_test.go satellite/accounting/tally: use objects iterator instead metaloop 2021-07-20 15:52:18 +00:00
db.go satellite/accounting: Correctly cache project bandwidth 2022-06-21 08:31:41 +00:00
projectlimitcache_test.go satellite/accounting: expose project segment limit 2021-12-08 11:27:21 +00:00
projectlimitcache.go satellite/accounting: expose project segment limit 2021-12-08 11:27:21 +00:00
projectusage_test.go satellite/accounting: modify tally.go to use returned segments values 2022-05-17 17:20:02 +00:00
projectusage.go satellite/accounting: Correctly cache project bandwidth 2022-06-21 08:31:41 +00:00