diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 0062c13bda5..76d64427e8a 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -758,7 +758,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { }, deleteTopic() { - this.unsubscribe(); this.get('content').destroy(Discourse.User.current()); }, diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index b1538585af6..c0ac588d942 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -109,8 +109,11 @@ class PostDestroyer # When a user 'deletes' their own post. We just change the text. def mark_for_deletion I18n.with_locale(SiteSetting.default_locale) do + + # don't call revise from within transaction, high risk of deadlock + @post.revise(@user, { raw: I18n.t('js.post.deleted_by_author', count: SiteSetting.delete_removed_posts_after) }, force_new_version: true) + Post.transaction do - @post.revise(@user, { raw: I18n.t('js.post.deleted_by_author', count: SiteSetting.delete_removed_posts_after) }, force_new_version: true) @post.update_column(:user_deleted, true) @post.update_flagged_posts_count @post.topic_links.each(&:destroy) @@ -122,9 +125,11 @@ class PostDestroyer Post.transaction do @post.update_column(:user_deleted, false) @post.skip_unique_check = true - @post.revise(@user, { raw: @post.revisions.last.modifications["raw"][0] }, force_new_version: true) @post.update_flagged_posts_count end + + # has internal transactions, if we nest then there are some very high risk deadlocks + @post.revise(@user, { raw: @post.revisions.last.modifications["raw"][0] }, force_new_version: true) end private