[sqlalchemy] Re: Strange caching problem with Apache
On Mar 29, 8:11 am, Lukasz Szybalski [EMAIL PROTECTED] wrote: On Fri, Mar 28, 2008 at 10:54 PM, Graham Dumpleton [EMAIL PROTECTED] wrote: On Mar 29, 11:02 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is 0. I also called session.clear() before using it. Unfortunately, the caching behavior persists. Any other suggestions? Thank you very much for your time and help! if its zero, then the Session isnt caching. Something is going on HTTP/process-wise. Could it be that because Apache is a multi process web server (on UNIX), that OP is getting confused through subsequent requests actually hitting a different process. That said, sqlalchemy as I understood it was meant to deal with that, ie., change made from one process should be reflected in another process straight away upon a new query, ie., cached data should be replaced. Is it possible that what ever insures that has been disabled. OP should perhaps print out os.getpid() so they know which process is handling the request each time. This may help to explain what is going on. Graham What are you using to handle http requests? turbogears? psp? Would converting from mod_python to mod_Wsgi help in this situation? Lucas I'm using mod_python's publisher handler to handle requests. I'm not familiar with mod_Wsgi, but I'll look into it. The plot thickens: I rewrote the function to just get a connection from the engine and send it raw SQL, and the caching behavior still persists. Thanks, john --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Strange caching problem with Apache
On Fri, Mar 28, 2008 at 10:54 PM, Graham Dumpleton [EMAIL PROTECTED] wrote: On Mar 29, 11:02 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is 0. I also called session.clear() before using it. Unfortunately, the caching behavior persists. Any other suggestions? Thank you very much for your time and help! if its zero, then the Session isnt caching. Something is going on HTTP/process-wise. Could it be that because Apache is a multi process web server (on UNIX), that OP is getting confused through subsequent requests actually hitting a different process. That said, sqlalchemy as I understood it was meant to deal with that, ie., change made from one process should be reflected in another process straight away upon a new query, ie., cached data should be replaced. Is it possible that what ever insures that has been disabled. OP should perhaps print out os.getpid() so they know which process is handling the request each time. This may help to explain what is going on. Graham What are you using to handle http requests? turbogears? psp? Would converting from mod_python to mod_Wsgi help in this situation? Lucas -- Automotive Recall Database. Cars, Trucks, etc. http://www.lucasmanual.com/recall/ TurboGears Documentation: http://www.lucasmanual.com/mywiki/TurboGears --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Strange caching problem with Apache
On Mar 28, 2008, at 6:42 PM, john spurling wrote: The funny part is that if I run this very same code in a standalone Python process (where the process is kept alive, like the Apache process), there is no caching behavior; the correct value is returned every single time. If it's run in Apache, I can see the incorrect value get returned in the logs (in the 'get_user' function above). In either case, I see the query getting logged in MySQL's query logs. Any ideas at all? I've searched through both the mod_python and sqlalchemy archives and haven't found anything appropriate. that is the symptom of a Session being reused - that the SQL is issued but it returns the existing identity map version. But the code you've illustrated should not have this problem since you are creating and closing a Session within the scope of a function call (but you said, that's only a synopsis of the code which I assume means it's not verbatim). I'd add logging which includes the in-memory identity of the Session in use as well as assertions that it's empty before use (assert len(list(session)) == 0). if a preceding session.clear() fixes the problem thats also a sign of that issue. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Strange caching problem with Apache
On Mar 28, 4:12 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 6:42 PM, john spurling wrote: The funny part is that if I run this very same code in a standalone Python process (where the process is kept alive, like the Apache process), there is no caching behavior; the correct value is returned every single time. If it's run in Apache, I can see the incorrect value get returned in the logs (in the 'get_user' function above). In either case, I see the query getting logged in MySQL's query logs. Any ideas at all? I've searched through both the mod_python and sqlalchemy archives and haven't found anything appropriate. that is the symptom of a Session being reused - that the SQL is issued but it returns the existing identity map version. But the code you've illustrated should not have this problem since you are creating and closing a Session within the scope of a function call (but you said, that's only a synopsis of the code which I assume means it's not verbatim). I'd add logging which includes the in-memory identity of the Session in use as well as assertions that it's empty before use (assert len(list(session)) == 0). if a preceding session.clear() fixes the problem thats also a sign of that issue. I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is 0. I also called session.clear() before using it. Unfortunately, the caching behavior persists. Any other suggestions? Thank you very much for your time and help! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Strange caching problem with Apache
On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is 0. I also called session.clear() before using it. Unfortunately, the caching behavior persists. Any other suggestions? Thank you very much for your time and help! if its zero, then the Session isnt caching. Something is going on HTTP/process-wise. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Strange caching problem with Apache
On Mar 29, 11:02 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is 0. I also called session.clear() before using it. Unfortunately, the caching behavior persists. Any other suggestions? Thank you very much for your time and help! if its zero, then the Session isnt caching. Something is going on HTTP/process-wise. Could it be that because Apache is a multi process web server (on UNIX), that OP is getting confused through subsequent requests actually hitting a different process. That said, sqlalchemy as I understood it was meant to deal with that, ie., change made from one process should be reflected in another process straight away upon a new query, ie., cached data should be replaced. Is it possible that what ever insures that has been disabled. OP should perhaps print out os.getpid() so they know which process is handling the request each time. This may help to explain what is going on. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Strange caching problem with Apache
On Mar 28, 2008, at 11:54 PM, Graham Dumpleton wrote: On Mar 29, 11:02 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is 0. I also called session.clear() before using it. Unfortunately, the caching behavior persists. Any other suggestions? Thank you very much for your time and help! if its zero, then the Session isnt caching. Something is going on HTTP/process-wise. Could it be that because Apache is a multi process web server (on UNIX), that OP is getting confused through subsequent requests actually hitting a different process. That said, sqlalchemy as I understood it was meant to deal with that, ie., change made from one process should be reflected in another process straight away upon a new query, ie., cached data should be replaced. Is it possible that what ever insures that has been disabled. OP should perhaps print out os.getpid() so they know which process is handling the request each time. This may help to explain what is going on. the only cache-like thing SA has is the session...and in this case we are starting from an empty session, so no caching is taking place. my next idea is that the UPDATE you're issuing is not being committed within its transaction so is not visible to other connections. Although thats unusual for MySQL since its commandline is usually in autocommit mode. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---