mastodon/app/services
Brian Campbell 2d12948220
Fix idempotency when database writes are slow (#21840)
There is an idempotency key generated by clients when authoring a post,
and stored in Redis, to ensure that if a user or client retries posting
the same status, we don't get a duplicate.

Hachyderm.io has been experiencing some filesystem and database
performance issues, causing database writes to be slow. This can mean
that there are successful posts, but the reverse proxy returns 504
Gateway Timeout before the idempotency status has been updated; users or
clients who retry (such as Tusky which retries automatically, see
tuskyapp/Tusky#2951) can re-try the same post with the same idempotency
key before it has actually been recorded in Redis, leading to duplicate
posts.

To address this issue, move all of the database updates after the
initial transaction that creates the status into the
`postprocess_status!` method, so we can insert the idempotency key
immediately after the status has been created, significantly reducing
the window in which the status could be created but the idempotency key
not yet stored.

Note: this has not yet been tested; I'm submitting this PR for
discussion and to offer to the Hachyderm.io admins to try out to fix the
multiple posting problem.

Co-authored-by: Brian Campbell <brcampbell@beta.team>
2022-12-15 18:08:40 +01:00
..
activitypub Fix unbounded recursion in account discovery (#22025) 2022-12-07 00:15:24 +01:00
concerns
keys
account_search_service.rb Improve performance by avoiding regex construction (#20215) 2022-11-10 05:49:30 +01:00
account_statuses_cleanup_service.rb Fix reblogs being discarded after the reblogged status (#19731) 2022-11-04 16:31:44 +01:00
after_block_domain_from_account_service.rb Fix account domain block not properly unfollowing accounts from domain (#14304) 2020-07-13 19:33:10 +02:00
after_block_service.rb
after_unallow_domain_service.rb
app_sign_up_service.rb
appeal_service.rb
approve_appeal_service.rb
authorize_follow_service.rb
backup_service.rb
base_service.rb
batched_remove_status_service.rb
block_domain_service.rb Add support for reversible suspensions through ActivityPub (#14989) 2020-11-08 00:28:39 +01:00
block_service.rb
bootstrap_timeline_service.rb Add customizable user roles (#18641) 2022-07-05 02:41:40 +02:00
clear_domain_media_service.rb
create_featured_tag_service.rb Fix Settings::FeaturedTagsController (#19418) 2022-10-22 23:14:58 +02:00
delete_account_service.rb Remove LDSignature on actor Delete activities (#21466) 2022-11-27 20:43:24 +01:00
deliver_to_device_service.rb
fan_out_on_write_service.rb Add caching for payload serialization during fan-out (#19642) 2022-11-04 13:21:06 +01:00
favourite_service.rb
fetch_link_card_service.rb
fetch_oembed_service.rb
fetch_remote_status_service.rb
fetch_resource_service.rb
follow_service.rb
import_service.rb Support UTF-8 Characters in Domains During CSV Import (#20592) 2022-11-14 05:52:13 +01:00
move_service.rb
mute_service.rb
notify_service.rb
post_status_service.rb Fix idempotency when database writes are slow (#21840) 2022-12-15 18:08:40 +01:00
precompute_feed_service.rb
process_hashtags_service.rb
process_mentions_service.rb Change mentions of blocked users to not be processed (#19725) 2022-11-04 13:19:12 +01:00
purge_domain_service.rb
reblog_service.rb
reject_follow_service.rb
remove_featured_tag_service.rb
remove_from_followers_service.rb Add remove from followers api (#16864) 2021-10-18 12:02:35 +02:00
remove_status_service.rb Fix n+1 query during status removal (#19753) 2022-11-05 00:09:52 +01:00
report_service.rb Change Report category to "violation" if rule IDs are provided (#20137) 2022-11-08 17:28:02 +01:00
resolve_account_service.rb Fix account migration form ever using outdated account data (#18429) 2022-10-29 01:31:45 +02:00
resolve_url_service.rb Improve performance by avoiding regex construction (#20215) 2022-11-10 05:49:30 +01:00
search_service.rb
suspend_account_service.rb
tag_search_service.rb
translate_status_service.rb
unallow_domain_service.rb Fix removing allowed domains being done synchronously (#14302) 2020-07-15 21:08:19 +02:00
unblock_domain_service.rb
unblock_service.rb
unfavourite_service.rb
unfollow_service.rb
unmute_service.rb
unsuspend_account_service.rb
update_account_service.rb Fix being able to spoof link verification (#20217) 2022-11-09 08:24:21 +01:00
update_status_service.rb
verify_link_service.rb Handle links with no href in VerifyLinkService (#20741) 2022-11-17 10:59:35 +01:00
vote_service.rb
webhook_service.rb