Try fixing ThreadResolveWorker calls (#3599)
Try fixing ThreadResolveWorker calls (#3599)

* Try fixing ThreadResolveWorker calls

From my understanding of ActiveRecord, a transaction is commited as soon as
the exit of the outmost ActiveRecord.transaction block. However, inner
transaction blocks will exit without the transaction being commited.

In this case, ThreadResolveWorker were fired *within* a transaction block,
so moving the call out of it should do the trick. However, this is somewhat
fragile, as this whole codepath could be called within yet another transaction.

* Set status thread within the transaction block if it is immediately available from database

masto-donte-com-br/mastodon,corzntin/mastodon,corzntin/mastodon,Arukas/mastodon,honpya/taketodon,abcang/mastodon,rainyday/mastodon,dwango/mastodon,ambition-vietnam/mastodon,rainyday/mastodon,vahnj/mastodon,h-izumi/mastodon,rekif/mastodon,TheInventrix/mastodon,pixiv/mastodon,anon5r/mastonon,anon5r/mastonon,hugogameiro/mastodon,summoners-riftodon/mastodon,verniy6462/mastodon,theoria24/mastodon,im-in-space/mastodon,Craftodon/Craftodon,5thfloor/ichiji-social,anon5r/mastonon,cobodo/mastodon,Kirishima21/mastodon,im-in-space/mastodon,musashino205/mastodon,ambition-vietnam/mastodon,ikuradon/mastodon,alarky/mastodon,res-ac/mstdn.res.ac,tri-star/mastodon,mhffdq/mastodon,foozmeat/mastodon,riku6460/chikuwagoddon,PlantsNetwork/mastodon,sylph-sin-tyaku/mastodon,codl/mastodon,rainyday/mastodon,cybrespace/mastodon,lynlynlynx/mastodon,maa123/mastodon,amazedkoumei/mastodon,esetomo/mastodon,haleyashleypraesent/ProjectPrionosuchus,increments/mastodon,pinfort/mastodon,hyuki0000/mastodon,pso2club/mastodon,riku6460/chikuwagoddon,musashino205/mastodon,pointlessone/mastodon,RobertRence/Mastodon,PlantsNetwork/mastodon,palon7/mastodon,ykzts/mastodon,Chronister/mastodon,yukimochi/mastodon,pfm-eyesightjp/mastodon,PlantsNetwork/mastodon,dunn/mastodon,pinfort/mastodon,rutan/mastodon,cobodo/mastodon,rekif/mastodon,imomix/mastodon,hyuki0000/mastodon,foozmeat/mastodon,MastodonCloud/mastodon,RobertRence/Mastodon,WitchesTown/mastodon,tateisu/mastodon,kagucho/mastodon,vahnj/mastodon,dunn/mastodon,amazedkoumei/mastodon,tootcafe/mastodon,tateisu/mastodon,masto-donte-com-br/mastodon,PlantsNetwork/mastodon,codl/mastodon,hugogameiro/mastodon,mosaxiv/mastodon,h3zjp/mastodon,danhunsaker/mastodon,MitarashiDango/mastodon,kagucho/mastodon,salvadorpla/mastodon,mosaxiv/mastodon,KnzkDev/mastodon,tri-star/mastodon,im-in-space/mastodon,imas/mastodon,h3zjp/mastodon,pointlessone/mastodon,dwango/mastodon,haleyashleypraesent/ProjectPrionosuchus,WitchesTown/mastodon,palon7/mastodon,corzntin/mastodon,hugogameiro/mastodon,Craftodon/Craftodon,NS-Kazuki/mastodon,rainyday/mastodon,nonoz/mastodon,Toootim/mastodon,rutan/mastodon,theoria24/mastodon,rekif/mastodon,masto-donte-com-br/mastodon,danhunsaker/mastodon,Toootim/mastodon,danhunsaker/mastodon,Nyoho/mastodon,Toootim/mastodon,imomix/mastodon,gol-cha/mastodon,pinfort/mastodon,WitchesTown/mastodon,kazh98/social.arnip.org,TheInventrix/mastodon,masarakki/mastodon,glitch-soc/mastodon,Nyoho/mastodon,blackle/mastodon,Kirishima21/mastodon,imas/mastodon,TheInventrix/mastodon,kazh98/social.arnip.org,mosaxiv/mastodon,dunn/mastodon,pso2club/mastodon,masarakki/mastodon,pso2club/mastodon,ikuradon/mastodon,alarky/mastodon,pfm-eyesightjp/mastodon,haleyashleypraesent/ProjectPrionosuchus,Ryanaka/mastodon,Chronister/mastodon,d6rkaiz/mastodon,yukimochi/mastodon,foozmeat/mastodon,imas/mastodon,kirakiratter/mastodon,summoners-riftodon/mastodon,dunn/mastodon,unarist/mastodon,masarakki/mastodon,Toootim/mastodon,honpya/taketodon,amazedkoumei/mastodon,mhffdq/mastodon,pixiv/mastodon,anon5r/mastonon,esetomo/mastodon,abcang/mastodon,amazedkoumei/mastodon,vahnj/mastodon,unarist/mastodon,corzntin/mastodon,Kirishima21/mastodon,musashino205/mastodon,mimumemo/mastodon,salvadorpla/mastodon,yukimochi/mastodon,codl/mastodon,h-izumi/mastodon,maa123/mastodon,d6rkaiz/mastodon,h-izumi/mastodon,increments/mastodon,nonoz/mastodon,riku6460/chikuwagoddon,WitchesTown/mastodon,tateisu/mastodon,honpya/taketodon,primenumber/mastodon,lindwurm/mastodon,koba-lab/mastodon,kirakiratter/mastodon,summoners-riftodon/mastodon,pointlessone/mastodon,honpya/taketodon,Ryanaka/mastodon,nonoz/mastodon,cobodo/mastodon,ikuradon/mastodon,abcang/mastodon,sylph-sin-tyaku/mastodon,yi0713/mastodon,kagucho/mastodon,koba-lab/mastodon,nonoz/mastodon,ykzts/mastodon,primenumber/mastodon,gol-cha/mastodon,riku6460/chikuwagoddon,h3zjp/mastodon,pointlessone/mastodon,unarist/mastodon,salvadorpla/mastodon,ambition-vietnam/mastodon,tootsuite/mastodon,d6rkaiz/mastodon,increments/mastodon,pinfort/mastodon,yi0713/mastodon,foozmeat/mastodon,dwango/mastodon,Ryanaka/mastodon,musashino205/mastodon,lindwurm/mastodon,MastodonCloud/mastodon,rekif/mastodon,mimumemo/mastodon,yi0713/mastodon,Craftodon/Craftodon,tri-star/mastodon,imomix/mastodon,cybrespace/mastodon,NS-Kazuki/mastodon,esetomo/mastodon,TheInventrix/mastodon,mstdn-jp/mastodon,h3zjp/mastodon,5thfloor/ichiji-social,lynlynlynx/mastodon,lynlynlynx/mastodon,koba-lab/mastodon,tootsuite/mastodon,primenumber/mastodon,KnzkDev/mastodon,ykzts/mastodon,NS-Kazuki/mastodon,TheInventrix/mastodon,SerCom-KC/mastodon,mimumemo/mastodon,SerCom-KC/mastodon,alarky/mastodon,mimumemo/mastodon,alarky/mastodon,salvadorpla/mastodon,ikuradon/mastodon,dwango/mastodon,kazh98/social.arnip.org,clworld/mastodon,unarist/mastodon,kazh98/social.arnip.org,Craftodon/Craftodon,codl/mastodon,increments/mastodon,res-ac/mstdn.res.ac,sylph-sin-tyaku/mastodon,rutan/mastodon,SerCom-KC/mastodon,mhffdq/mastodon,gol-cha/mastodon,tootsuite/mastodon,cobodo/mastodon,Arukas/mastodon,esetomo/mastodon,tootcafe/mastodon,maa123/mastodon,glitch-soc/mastodon,pixiv/mastodon,tootcafe/mastodon,blackle/mastodon,mstdn-jp/mastodon,d6rkaiz/mastodon,palon7/mastodon,mosaxiv/mastodon,glitch-soc/mastodon,5thfloor/ichiji-social,mstdn-jp/mastodon,ambition-vietnam/mastodon,lindwurm/mastodon,tri-star/mastodon,verniy6462/mastodon,gol-cha/mastodon,kirakiratter/mastodon,cybrespace/mastodon,blackle/mastodon,abcang/mastodon,sylph-sin-tyaku/mastodon,ykzts/mastodon,5thfloor/ichiji-social,Nyoho/mastodon,clworld/mastodon,imas/mastodon,maa123/mastodon,MitarashiDango/mastodon,summoners-riftodon/mastodon,verniy6462/mastodon,haleyashleypraesent/ProjectPrionosuchus,tootsuite/mastodon,kirakiratter/mastodon,Ryanaka/mastodon,rutan/mastodon,yukimochi/mastodon,KnzkDev/mastodon,lynlynlynx/mastodon,mhffdq/mastodon,MastodonCloud/mastodon,cybrespace/mastodon,imomix/mastodon,theoria24/mastodon,res-ac/mstdn.res.ac,RobertRence/Mastodon,KnzkDev/mastodon,lindwurm/mastodon,MastodonCloud/mastodon,clworld/mastodon,mstdn-jp/mastodon,vahnj/mastodon,pixiv/mastodon,pfm-eyesightjp/mastodon,NS-Kazuki/mastodon,palon7/mastodon,tootcafe/mastodon,hyuki0000/mastodon,pfm-eyesightjp/mastodon,pso2club/mastodon,glitch-soc/mastodon,masarakki/mastodon,SerCom-KC/mastodon,verniy6462/mastodon,hyuki0000/mastodon,clworld/mastodon,Arukas/mastodon,yi0713/mastodon,Chronister/mastodon,h-izumi/mastodon,koba-lab/mastodon,Arukas/mastodon,masto-donte-com-br/mastodon,primenumber/mastodon,blackle/mastodon,im-in-space/mastodon,theoria24/mastodon,MitarashiDango/mastodon,vahnj/mastodon,Chronister/mastodon,Nyoho/mastodon,res-ac/mstdn.res.ac,tateisu/mastodon,MitarashiDango/mastodon,RobertRence/Mastodon,Kirishima21/mastodon,hugogameiro/mastodon,kagucho/mastodon,danhunsaker/mastodon