update to rails 4.2.5.1, add debugging info for tracking slow queries

This commit is contained in:
r888888888 2016-02-23 16:33:43 -08:00
parent bb3eb9f980
commit 4b24a5cb7e
13 changed files with 670 additions and 646 deletions

View File

@ -47,7 +47,6 @@ gem 'capistrano-rbenv'
gem 'radix62', '~> 1.0.1'
gem 'streamio-ffmpeg'
gem 'rubyzip', :require => "zip"
gem 'coinbase'
gem 'stripe'
gem 'twitter'
gem 'aws-sdk', '~> 2'

View File

@ -14,36 +14,36 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
actionmailer (4.2.5.1)
actionpack (= 4.2.5.1)
actionview (= 4.2.5.1)
activejob (= 4.2.5.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.3)
actionview (= 4.2.3)
activesupport (= 4.2.3)
actionpack (4.2.5.1)
actionview (= 4.2.5.1)
activesupport (= 4.2.5.1)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.3)
activesupport (= 4.2.3)
actionview (4.2.5.1)
activesupport (= 4.2.5.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.3)
activesupport (= 4.2.3)
activejob (4.2.5.1)
activesupport (= 4.2.5.1)
globalid (>= 0.3.0)
activemodel (4.2.3)
activesupport (= 4.2.3)
activemodel (4.2.5.1)
activesupport (= 4.2.5.1)
builder (~> 3.1)
activerecord (4.2.3)
activemodel (= 4.2.3)
activesupport (= 4.2.3)
activerecord (4.2.5.1)
activemodel (= 4.2.5.1)
activesupport (= 4.2.5.1)
arel (~> 6.0)
activesupport (4.2.3)
activesupport (4.2.5.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
@ -64,7 +64,6 @@ GEM
bcrypt (>= 3.1.3)
bcrypt-ruby (3.1.5-x64-mingw32)
bcrypt (>= 3.1.3)
bigdecimal (1.2.7)
buftok (0.2.0)
builder (3.2.2)
byebug (6.0.0)
@ -92,8 +91,6 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
coinbase (4.0.7)
bigdecimal
colorize (0.7.7)
crack (0.4.2)
safe_yaml (~> 1.0.0)
@ -151,9 +148,9 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.8.0)
mime-types (2.99.1)
mini_portile2 (2.0.0)
minitest (5.8.4)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.11.2)
@ -168,10 +165,10 @@ GEM
net-ssh (2.9.2)
netrc (0.10.3)
newrelic_rpm (3.13.0.299)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
nokogiri (1.6.6.2-x64-mingw32)
mini_portile (~> 0.6.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
nokogiri (1.6.7.2-x64-mingw32)
mini_portile2 (~> 2.0.0.rc2)
nokogumbo (1.2.0)
nokogiri
ntlm-http (0.1.1)
@ -192,16 +189,16 @@ GEM
rack-test (0.6.3)
rack (>= 1.0)
radix62 (1.0.1)
rails (4.2.3)
actionmailer (= 4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
activemodel (= 4.2.3)
activerecord (= 4.2.3)
activesupport (= 4.2.3)
rails (4.2.5.1)
actionmailer (= 4.2.5.1)
actionpack (= 4.2.5.1)
actionview (= 4.2.5.1)
activejob (= 4.2.5.1)
activemodel (= 4.2.5.1)
activerecord (= 4.2.5.1)
activesupport (= 4.2.5.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.3)
railties (= 4.2.5.1)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
@ -209,15 +206,15 @@ GEM
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.3)
actionpack (= 4.2.3)
activesupport (= 4.2.3)
railties (4.2.5.1)
actionpack (= 4.2.5.1)
activesupport (= 4.2.5.1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.15.0)
rake (10.4.2)
rake (10.5.0)
ref (2.0.0)
responders (2.1.0)
railties (>= 4.2.0, < 5)
@ -265,7 +262,7 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.3.2)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
@ -337,7 +334,6 @@ DEPENDENCIES
capistrano-rbenv
capistrano3-unicorn
coffee-rails
coinbase
daemons
dalli
delayed_job
@ -386,4 +382,4 @@ DEPENDENCIES
whenever
BUNDLED WITH
1.10.0
1.11.2

View File

@ -12,7 +12,7 @@ module Moderator
CurrentUser.without_safe_mode do
CurrentUser.scoped(updater, updater_ip_addr) do
::Post.tag_match(antecedent).find_each do |post|
::Post.tag_match(antecedent).where("true /* Moderator::TagBatchChange#perform */").find_each do |post|
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
post.update_attributes(:tag_string => tags)
end

View File

@ -9,7 +9,7 @@ module PostSets
def posts
@posts ||= begin
query = ::Post.tag_match(@artist.name).limit(10)
query = ::Post.tag_match(@artist.name).where("true /* PostSets::Artist#posts */").limit(10)
query.each # hack to force rails to eager load
query
end

View File

@ -70,7 +70,7 @@ module PostSets
end
def has_deleted?
tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists?
tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").where("true /* PostSets::Post#has_deleted */").exists?
end
def has_explicit?
@ -127,9 +127,9 @@ module PostSets
if random
temp = get_random_posts()
elsif raw
temp = ::Post.raw_tag_match(tag_string).order("posts.id DESC").paginate(page, :count => post_count, :limit => per_page)
temp = ::Post.raw_tag_match(tag_string).order("posts.id DESC").where("true /* PostSets::Post#posts:1 */").paginate(page, :count => post_count, :limit => per_page)
else
temp = ::Post.tag_match(tag_string, read_only).paginate(page, :count => post_count, :limit => per_page)
temp = ::Post.tag_match(tag_string, read_only).where("true /* PostSets::Post#posts:2 */").paginate(page, :count => post_count, :limit => per_page)
end
temp.each # hack to force rails to eager load
temp

View File

@ -53,9 +53,9 @@ class RelatedTagCalculator
candidates = convert_hash_to_array(counts, 100)
similar_counts = Hash.new {|h, k| h[k] = 0}
CurrentUser.without_safe_mode do
Post.with_timeout(5_000) do
PostReadOnly.with_timeout(5_000) do
candidates.each do |ctag, _|
acount = Post.tag_match("#{tag} #{ctag}").count
acount = PostReadOnly.tag_match("#{tag} #{ctag}").count
ctag_record = Tag.find_by_name(ctag)
div = Math.sqrt(tag_record.post_count * ctag_record.post_count)
if div != 0

View File

@ -6,7 +6,7 @@ class UserDeletion
def self.remove_favorites_for(user_id)
user = User.find(user_id)
Post.without_timeout do
Post.raw_tag_match("fav:#{user_id}").find_each do |post|
Post.raw_tag_match("fav:#{user_id}").where("true /* UserDeletion.remove_favorites_for */").find_each do |post|
Favorite.remove(post, user)
end
end

View File

@ -183,7 +183,7 @@ class Artist < ActiveRecord::Base
if params[:name]
artist.name = params[:name]
post = CurrentUser.without_safe_mode do
Post.tag_match("source:http #{artist.name}").first
Post.tag_match("source:http #{artist.name}").where("true /* Artist.new_with_defaults */").first
end
unless post.nil? || post.source.blank?
artist.url_string = post.source
@ -271,7 +271,7 @@ class Artist < ActiveRecord::Base
ti.destroy if ti
begin
Post.tag_match(name).each do |post|
Post.tag_match(name).where("true /* Artist.unban */").each do |post|
post.unban!
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
post.update_attributes(:tag_string => fixed_tags)
@ -289,7 +289,7 @@ class Artist < ActiveRecord::Base
Post.transaction do
CurrentUser.without_safe_mode do
begin
Post.tag_match(name).each do |post|
Post.tag_match(name).where("true /* Artist.ban */").each do |post|
post.ban!
end
rescue Post::SearchError

View File

@ -71,7 +71,7 @@ class Tag < ActiveRecord::Base
end
def real_post_count
@real_post_count ||= Post.raw_tag_match(name).count
@real_post_count ||= Post.raw_tag_match(name).where("true /* Tag#real_post_count */").count
end
def fix_post_count
@ -131,7 +131,7 @@ class Tag < ActiveRecord::Base
def update_category_post_counts
Post.with_timeout(30_000, nil) do
Post.raw_tag_match(name).find_each do |post|
Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
post.reload
post.set_tag_counts
Post.where(:id => post.id).update_all(:tag_count => post.tag_count, :tag_count_general => post.tag_count_general, :tag_count_artist => post.tag_count_artist, :tag_count_copyright => post.tag_count_copyright, :tag_count_character => post.tag_count_character)

View File

@ -186,7 +186,7 @@ class TagImplication < ActiveRecord::Base
def update_posts
Post.without_timeout do
Post.raw_tag_match(antecedent_name).find_each do |post|
Post.raw_tag_match(antecedent_name).where("true /* TagImplication#update_posts */").find_each do |post|
fixed_tags = "#{post.tag_string} #{descendant_names}".strip
CurrentUser.scoped(creator, creator_ip_addr) do
post.update_attributes(

View File

@ -1,5 +1,5 @@
class AddIndexToArtistGroupName < ActiveRecord::Migration
def change
add_index :artists, :group_name
# add_index :artists, :group_name
end
end

View File

@ -1,4 +1,5 @@
require 'set'
require 'timecop'
CurrentUser.ip_addr = "127.0.0.1"
Delayed::Worker.delay_jobs = false
@ -38,11 +39,14 @@ end
if User.count == 0
puts "Creating users"
user = User.create(
:name => "admin",
:password => "password1",
:password_confirmation => "password1"
)
Timecop.travel(1.month.ago) do
user = User.create(
:name => "admin",
:password => "password1",
:password_confirmation => "password1"
)
end
0.upto(10) do |i|
User.create(
@ -69,7 +73,7 @@ if Upload.count == 0
url = "http://ipsumimage.appspot.com/#{width}x#{height}"
tags = rand_sentence(12).scan(/[a-z]+/).join(" ")
Upload.create(:source => url, :content_type => "image/gif", :rating => "q", :tag_string => tags, :server => Socket.gethostname)
Upload.create!(:source => url, :content_type => "image/gif", :rating => "q", :tag_string => tags, :server => Socket.gethostname)
end
else
puts "Skipping uploads"

File diff suppressed because it is too large Load Diff