Hi! I think today I faced the bug who others already had when using mod_fastcgi: Sometimes a page crashes and sometimes not. What I did was to stop Apache, update the database (adding a new property), update the app and restart Apache. The first thing I noticed was that sometimes my model didn''t know about the new property. After digging more into the problem I noticed a lot of serialized sessions in /tmp. Now, could it be that Rails doesn''t clean up old sessions when using mod_fastcgi? Because if not would it be possible that the following could happen: 1. New User U visits the site and gets session S assigned by using a cookie 1. Controller adds model A to session S 2. Admin stops Apache 3. Admin installs new version of model A 4. Admin starts Apache 5. User U gets session S reassigned because he still has the cookie 6. Rails gets confused because it has two different versions of model A (old one in the session and new one on fs) Could this be the problem? Regards, Lars -- "Stil ist die Fähigkeit, komplizierte Dinge einfach zu sagen - nicht umgekehrt." -- Cocteau, Jean
You seem to understand what''s going on. One thing you could try is using ActiveRecord#reload to update the attributes in the database from your application after pulling objects out of a session. The cost of a simple query like this (in mysql, especially) is very small, and a few developers here seem only to be storing id''s in the session and using the id''s to pull out objects on demand to prevent stale data from creeping in. I myself an strongly contemplating doing this in my own code. The other thing, of course, is that this would never happen in production, since it would probably be prudent to flush sessions before enacting a schema change. I keep my sessions in the db rather than in /tmp to make this process that much easier (a trip in with myadmin). AFAIK, sessions last forever unless you write code to change that in your app. You don''t want all data expiring every server reload (which is what you seem to be suggesting). Think about what would happen in a shared hosting environment. Since rails/fastcgi have no way of knowing the admministrator''s intent in a reload/reset, it''s not reasonable to expect it to flush sessions only at the appropriate times. Brian On Fri, 18 Feb 2005 17:26:51 +0100, Lars Hoss <woeye-DgJLf6aGC0jR7s880joybQ@public.gmane.org> wrote:> Hi! > > I think today I faced the bug who others already had when using > mod_fastcgi: Sometimes a page crashes and sometimes not. > What I did was to stop Apache, update the database (adding a new > property), update the app and restart Apache. The first thing I noticed > was that sometimes my model didn''t know about the new property. After > digging more into the problem I noticed a lot of serialized sessions in > /tmp. > Now, could it be that Rails doesn''t clean up old sessions when using > mod_fastcgi? Because if not would it be possible that the following > could happen: > > 1. New User U visits the site and gets session S assigned by using a > cookie > 1. Controller adds model A to session S > 2. Admin stops Apache > 3. Admin installs new version of model A > 4. Admin starts Apache > 5. User U gets session S reassigned because he still has the cookie > 6. Rails gets confused because it has two different versions of model A > (old one in the session and new one on fs) > > Could this be the problem? > > Regards, > Lars > > -- > "Stil ist die Fähigkeit, komplizierte Dinge einfach zu sagen - nicht > umgekehrt." -- Cocteau, Jean > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- The years ahead pick up their dark bags. They move closer. There''s a slight rise in the silence then nothing. -- (If you''re receiving this in response to mail sent to bluczkie-OM76b2Iv3yLQjUSlxSEPGw@public.gmane.org, don''t be concerned This is my new address, but mail will be forwarded here indefinitely)
Is there a way to relocate where ruby_sess.* files get written? In the PHP world, we''ve used an NFS mount for session files, to aid in clustering. Is anyone doing this with Ruby? On a related note, I''ve been trying to get Apache FCGI working, and have run into problems with the permissions the ruby_sess.* files are given. On my OS X laptop, Apache writes them as www/wheel, whereas Webrick writes them as <mylogin>/wheel, since I''m running Webrick interactively from a terminal window. Then, since each web server has trouble reading the other''s session files, both throw errors, with Apache giving a 500 error, and Webrick saying "Not Found". Is there a way to control the permissions with which these files are written? Thanks! I''m certainly enjoying Rails. In two days I got quite a lot of functionality up and working--what a productive environment! Dave On 2/18/05 4:19 PM, "Brian L." <zorander-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> schema change. I keep my sessions in the db rather > than in /tmp to make this process that much easier (a trip in with > myadmin).
On Fri, 2005-02-18 at 17:21 -0700, Dave Ringoen wrote:> Is there a way to relocate where ruby_sess.* files get written? > > In the PHP world, we''ve used an NFS mount for session files, to aid in > clustering. Is anyone doing this with Ruby? > > On a related note, I''ve been trying to get Apache FCGI working, and have run > into problems with the permissions the ruby_sess.* files are given. On my OS > X laptop, Apache writes them as www/wheel, whereas Webrick writes them as > <mylogin>/wheel, since I''m running Webrick interactively from a terminal > window. Then, since each web server has trouble reading the other''s session > files, both throw errors, with Apache giving a 500 error, and Webrick saying > "Not Found". Is there a way to control the permissions with which these > files are written? > > Thanks! I''m certainly enjoying Rails. In two days I got quite a lot of > functionality up and working--what a productive environment! > > Dave >You could change your NFS settings to allow the user that webrick is running as. Or use sudo:> NAME > sudo - execute a command as another user(assuming you''re int eh *nix world( -Robby -- /*************************************** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | robby-/Lcn8Y7Ot69QmPsQ1CNsNQ@public.gmane.org * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development * --- Now hosting Ruby on Rails Apps --- ****************************************/
On Fri, 18 Feb 2005, Dave Ringoen wrote:> Is there a way to relocate where ruby_sess.* files get written? > > In the PHP world, we''ve used an NFS mount for session files, to aid in > clustering. Is anyone doing this with Ruby? > > On a related note, I''ve been trying to get Apache FCGI working, and have run > into problems with the permissions the ruby_sess.* files are given. On my OS > X laptop, Apache writes them as www/wheel, whereas Webrick writes them as > <mylogin>/wheel, since I''m running Webrick interactively from a terminal > window. Then, since each web server has trouble reading the other''s session > files, both throw errors, with Apache giving a 500 error, and Webrick saying > "Not Found". Is there a way to control the permissions with which these > files are written? > > Thanks! I''m certainly enjoying Rails. In two days I got quite a lot of > functionality up and working--what a productive environment! > > Davebe very, very careful with this. i know only a little about rails sessions but do know that they use PStore which , itself, uses flock. flock is NOT NFS clean and even throws exceptions on newer redhats. if you access sessions from multiple hosts simoultaneously you will corrupt the sesions''s pstore. i have a small module which will make PStore NFS clean, and other nfs locking utilities, if you are interested. cheers. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
Dave Ringoen wrote:> Is there a way to relocate where ruby_sess.* files get written? > > In the PHP world, we''ve used an NFS mount for session files, to aid in > clustering. Is anyone doing this with Ruby?Consider running ActiveRecordStore against MySQL + MyISAM (fast) sessions table. This makes clustering easy and eliminates filesystem woes. jeremy