WIP: Set backdated timestamp IDs on new old Statuses#5211
Closed
aschmitz wants to merge 1 commit intomastodon:masterfrom
Closed
WIP: Set backdated timestamp IDs on new old Statuses#5211aschmitz wants to merge 1 commit intomastodon:masterfrom
aschmitz wants to merge 1 commit intomastodon:masterfrom
Conversation
Contributor
Author
|
This is based on #4801, and appears to work in some cursory testing, but is marked a WIP because it needs tests. |
Member
|
Time to rebase! I usually do a branch switcharoo with cherry-pick on the latest commit to make things right. |
Contributor
|
Things I afraid about toot backfillings.
I think normal arriving remote status should be numbered by arriving time and reject futute publish time for backfillings(boosted original status, searched status, importing, etc). |
Member
|
Solutions:
|
For any "old" status (where the creation time is before the update time, as both are already set by Rails by the time we get to around_save), we now generate an ID for the "old" (or potentially, future-dated) status, and attempt to use that to insert. In the vast majority of cases, this should succeed. If it doesn't, we retry up to a thousand times, each time incrementing the ID by a random number between 0 and 99, to avoid too many collisions. Note that this also necessitates setting `created_at` to nil (or leaving it unset), not Time.utc.now, when creating new statuses. (Although the only downside to setting a time is a small amount of extra work, nothing catastrophic.)
248d6f5 to
82050c9
Compare
nightpool
reviewed
Oct 6, 2017
| # repeatedly querying the same set of IDs in such a case. | ||
| # (This mostly exists to avoid a DoS attack, and should | ||
| # rarely be useful under normal circumstances.) | ||
| obj.id = rand(100) if tries.positive? |
Contributor
Author
|
Closing this in favor of #5260. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For any "old" status (where the creation time is before the update time, as both are already set by Rails by the time we get to around_save), we now generate an ID for the "old" (or potentially, future-dated) status, and attempt to use that to insert.
In the vast majority of cases, this should succeed. If it doesn't, we retry up to a thousand times, each time incrementing the ID by a random number between 0 and 99, to avoid too many collisions.
Note that this also necessitates setting
created_atto nil (or leaving it unset), not Time.utc.now, when creating new statuses. (Although the only downside to setting a time is a small amount of extra work, nothing catastrophic.)