storj/satellite/metainfo
Cameron Ayer 4424697d7f satellite/accounting: refactor live accounting to hold current estimated totals
live accounting used to be a cache to store writes before they are picked up during
the tally iteration, after which the cache is cleared. This created a window in which
users could potentially exceed the storage limit. This PR refactors live accounting to
hold current estimations of space used per project. This should also reduce DB load
since we no longer need to query the satellite DB when checking space used for limiting.

The mechanism by which the new live accounting system works is as follows:

During the upload of any segment, the size of that segment is added to its respective
project total in live accounting. At the beginning of the tally iteration we record
the current values in live accounting as `initialLiveTotals`. At the end of the tally
iteration we again record the current totals in live accounting as `latestLiveTotals`.
The metainfo loop observer in tally allows us to get the project totals from what it
observed in metainfo DB which are stored in `tallyProjectTotals`. However, for any
particular segment uploaded during the metainfo loop, the observer may or may not
have seen it. Thus, we take half of the difference between `latestLiveTotals` and
`initialLiveTotals`, and add that to the total that was found during tally and set that
as the new live accounting total.

Initially, live accounting was storing the total stored amount across all nodes rather than
the segment size, which is inconsistent with how we record amounts stored in the project
accounting DB, so we have refactored live accounting to record segment size

Change-Id: Ie48bfdef453428fcdc180b2d781a69d58fd927fb
2020-01-16 10:26:49 -05:00
..
batch.go common: separate repository 2019-12-27 14:11:15 +02:00
config.go postgres2: use cockroachkv impl against postgres 2020-01-13 14:51:56 -06:00
db_test.go common: separate repository 2019-12-27 14:11:15 +02:00
db.go common: separate repository 2019-12-27 14:11:15 +02:00
delete_pieces_service_test.go satellite/metainfo: Create service for deleting pieces 2020-01-15 15:24:20 +01:00
delete_pieces_service.go satellite/metainfo: Create service for deleting pieces 2020-01-15 15:24:20 +01:00
endpoint_test.go satellite/metainfo: Add back-pressure mechanism DeleteObjectPieces 2020-01-09 08:22:11 +00:00
loop_test.go common: separate repository 2019-12-27 14:11:15 +02:00
loop.go satellite/metainfo: Fixed bug that discarded context cancellation errors 2020-01-03 22:48:12 -05:00
metainfo_old_test.go uplink: move to storj.io/uplink (#3746) 2020-01-08 15:40:19 +02:00
metainfo_test.go uplink: move to storj.io/uplink (#3746) 2020-01-08 15:40:19 +02:00
metainfo.go satellite/accounting: refactor live accounting to hold current estimated totals 2020-01-16 10:26:49 -05:00
service_test.go private/testplanet: remove dependency to uplink 2020-01-02 09:40:46 +00:00
service.go uplink: move to storj.io/uplink (#3746) 2020-01-08 15:40:19 +02:00
validation.go common: separate repository 2019-12-27 14:11:15 +02:00