Skip to content

Commit d6d31de

Browse files
committed
add to build script, explicitly eager load the Script's db connection if Marshal fails because its stuff isn't loaded
1 parent 22f0318 commit d6d31de

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

aws/build.rake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ $websites = build_task('websites', [deploy_dir('rebuild'), BLOCKLY_COMMIT_TASK])
158158
RakeUtils.system 'rake', 'build'
159159

160160
if rack_env?(:production) && CDO.daemon
161+
HipChat.log "Putting <b>dashboard</b> scripts in redis..."
162+
RakeUtils.rake 'seed:script_cache_to_redis'
163+
161164
thread_count = 1 + (CDO.app_servers.keys.count / 10)
162165
threaded_each CDO.app_servers.keys, thread_count do |name|
163166
upgrade_frontend name, CDO.app_servers[name]

dashboard/app/models/script.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,21 @@ def self.redis
8080
def self.script_cache_from_redis
8181
return unless redis
8282
if marshalled = self.redis['script-cache']
83-
Marshal.load marshalled
83+
begin
84+
retried = false
85+
Marshal.load marshalled
86+
rescue NameError
87+
# rails tries to do some fancy lazy loading of the database
88+
# connection. If, somehow, this is called before we ever load
89+
# a Script from the database, Marshal.load will get confused
90+
# because not all of the classes Script depends on are
91+
# loaded. Do a silly query to get everything loaded first.
92+
self.exists?
93+
unless retried
94+
retried = true
95+
retry
96+
end
97+
end
8498
end
8599
end
86100

0 commit comments

Comments
 (0)