[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-24 Thread Lisandro
Hi Massimo, thank you for your time.
I had marked this thread as "no action needed" because I found the cause of 
the issue.

First I thought it was a different problem, so I opened a new thread in 
this forum:
https://groups.google.com/forum/#!topic/web2py/E9jrmf5E-B4
The title of that thread is not correct. I ended up finding that the 
problem is generated in some specific situations, and a specific key can't 
be stored at redis cache. In that thread I've posted some details about the 
tests I made to figure out that was the root cause. 

Sorry if I created some confusion opening a new thread, won't happen again 
:)


El martes, 24 de abril de 2018, 18:43:09 (UTC-3), Massimo Di Pierro 
escribió:
>
> That query itself cannot case hanging but maybe when that query is 
> executed the database is busy with some other background task?
> Try setting migrations to false. may be you are doing more database IO 
> than you should
>
> On Friday, 6 April 2018 09:41:09 UTC-5, Lisandro wrote:
>>
>> Hi Anthony, again, thank you very much for your time, I really appreciate 
>> it.
>>
>> El jueves, 5 de abril de 2018, 17:52:36 (UTC-3), Anthony escribió:
>>>
>>> On Thursday, April 5, 2018 at 2:57:20 PM UTC-4, Lisandro wrote:

 Thank you Anthony, yes I'm aware of that.
 I use it like that for this reason: sometimes (not very often) an 
 external app modifies a field of the auth_user table (specifically, it 
 sets 
 true or false a field that I use as a flag). However that change isn't 
 updated to auth.user. In order to do so, the user needs to logout and 
 login 
 again. So I retrieve the auth_user record again and store it to 
 response.answer.

 Maybe it could be done like this:
 if auth.is_logged_in():
 auth.user = db.auth_user[auth.user.id]

 But I thought it could be break something with Auth methods, so I store 
 it in response.user.

>>>
>>> Got it. Yeah, don't replace auth.user -- create a separate variable.
>>>  
>>>
 Anyway, I set this topic as "no action needed" because I opened a new 
 topic, I've found some more info and I think the issue isn't related to 
 that sentence.

>>>
>>> But you indicated the select generated by that code was causing Postgres 
>>> to hang. Are you sure that is the case? In other words, is the web2py code 
>>> getting stuck at that line and ultimately causing your server to time out? 
>>> Have you tried adding some logging statements to your code to determine 
>>> exactly where it is getting stuck?
>>>
>>
>> To be truth, I'm not exactly sure that is the line where the code hangs, 
>> I supposed that because of the select query taking too long, but I can't be 
>> sure.
>> The problem is that the incident presents sporadically, and the worst 
>> part is that I can't reproduce it. Also, as it happens in the production 
>> server, I can't afford to modify the app code in production, giving that I 
>> would be making changes to an application that is used by our customers, so 
>> I'm in a tricky situation. 
>>
>> I've made have plans to move sessions to Redis, but as a developer, I 
>> would still like to understand the root cause of the issue :)
>>
>> Anyway, I'll wait to the incident happens again, hoping that it happens 
>> in an app of a "small" customer so I can do some tests.
>>
>>
>>  
>>
>>>
>>> Anthony
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-24 Thread Massimo Di Pierro
That query itself cannot case hanging but maybe when that query is executed 
the database is busy with some other background task?
Try setting migrations to false. may be you are doing more database IO than 
you should

On Friday, 6 April 2018 09:41:09 UTC-5, Lisandro wrote:
>
> Hi Anthony, again, thank you very much for your time, I really appreciate 
> it.
>
> El jueves, 5 de abril de 2018, 17:52:36 (UTC-3), Anthony escribió:
>>
>> On Thursday, April 5, 2018 at 2:57:20 PM UTC-4, Lisandro wrote:
>>>
>>> Thank you Anthony, yes I'm aware of that.
>>> I use it like that for this reason: sometimes (not very often) an 
>>> external app modifies a field of the auth_user table (specifically, it sets 
>>> true or false a field that I use as a flag). However that change isn't 
>>> updated to auth.user. In order to do so, the user needs to logout and login 
>>> again. So I retrieve the auth_user record again and store it to 
>>> response.answer.
>>>
>>> Maybe it could be done like this:
>>> if auth.is_logged_in():
>>> auth.user = db.auth_user[auth.user.id]
>>>
>>> But I thought it could be break something with Auth methods, so I store 
>>> it in response.user.
>>>
>>
>> Got it. Yeah, don't replace auth.user -- create a separate variable.
>>  
>>
>>> Anyway, I set this topic as "no action needed" because I opened a new 
>>> topic, I've found some more info and I think the issue isn't related to 
>>> that sentence.
>>>
>>
>> But you indicated the select generated by that code was causing Postgres 
>> to hang. Are you sure that is the case? In other words, is the web2py code 
>> getting stuck at that line and ultimately causing your server to time out? 
>> Have you tried adding some logging statements to your code to determine 
>> exactly where it is getting stuck?
>>
>
> To be truth, I'm not exactly sure that is the line where the code hangs, I 
> supposed that because of the select query taking too long, but I can't be 
> sure.
> The problem is that the incident presents sporadically, and the worst part 
> is that I can't reproduce it. Also, as it happens in the production server, 
> I can't afford to modify the app code in production, giving that I would be 
> making changes to an application that is used by our customers, so I'm in a 
> tricky situation. 
>
> I've made have plans to move sessions to Redis, but as a developer, I 
> would still like to understand the root cause of the issue :)
>
> Anyway, I'll wait to the incident happens again, hoping that it happens in 
> an app of a "small" customer so I can do some tests.
>
>
>  
>
>>
>> Anthony
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-06 Thread Lisandro
Hi Anthony, again, thank you very much for your time, I really appreciate 
it.

El jueves, 5 de abril de 2018, 17:52:36 (UTC-3), Anthony escribió:
>
> On Thursday, April 5, 2018 at 2:57:20 PM UTC-4, Lisandro wrote:
>>
>> Thank you Anthony, yes I'm aware of that.
>> I use it like that for this reason: sometimes (not very often) an 
>> external app modifies a field of the auth_user table (specifically, it sets 
>> true or false a field that I use as a flag). However that change isn't 
>> updated to auth.user. In order to do so, the user needs to logout and login 
>> again. So I retrieve the auth_user record again and store it to 
>> response.answer.
>>
>> Maybe it could be done like this:
>> if auth.is_logged_in():
>> auth.user = db.auth_user[auth.user.id]
>>
>> But I thought it could be break something with Auth methods, so I store 
>> it in response.user.
>>
>
> Got it. Yeah, don't replace auth.user -- create a separate variable.
>  
>
>> Anyway, I set this topic as "no action needed" because I opened a new 
>> topic, I've found some more info and I think the issue isn't related to 
>> that sentence.
>>
>
> But you indicated the select generated by that code was causing Postgres 
> to hang. Are you sure that is the case? In other words, is the web2py code 
> getting stuck at that line and ultimately causing your server to time out? 
> Have you tried adding some logging statements to your code to determine 
> exactly where it is getting stuck?
>

To be truth, I'm not exactly sure that is the line where the code hangs, I 
supposed that because of the select query taking too long, but I can't be 
sure.
The problem is that the incident presents sporadically, and the worst part 
is that I can't reproduce it. Also, as it happens in the production server, 
I can't afford to modify the app code in production, giving that I would be 
making changes to an application that is used by our customers, so I'm in a 
tricky situation. 

I've made have plans to move sessions to Redis, but as a developer, I would 
still like to understand the root cause of the issue :)

Anyway, I'll wait to the incident happens again, hoping that it happens in 
an app of a "small" customer so I can do some tests.


 

>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-05 Thread Anthony
On Thursday, April 5, 2018 at 2:57:20 PM UTC-4, Lisandro wrote:
>
> Thank you Anthony, yes I'm aware of that.
> I use it like that for this reason: sometimes (not very often) an external 
> app modifies a field of the auth_user table (specifically, it sets true or 
> false a field that I use as a flag). However that change isn't updated to 
> auth.user. In order to do so, the user needs to logout and login again. So 
> I retrieve the auth_user record again and store it to response.answer.
>
> Maybe it could be done like this:
> if auth.is_logged_in():
> auth.user = db.auth_user[auth.user.id]
>
> But I thought it could be break something with Auth methods, so I store it 
> in response.user.
>

Got it. Yeah, don't replace auth.user -- create a separate variable.
 

> Anyway, I set this topic as "no action needed" because I opened a new 
> topic, I've found some more info and I think the issue isn't related to 
> that sentence.
>

But you indicated the select generated by that code was causing Postgres to 
hang. Are you sure that is the case? In other words, is the web2py code 
getting stuck at that line and ultimately causing your server to time out? 
Have you tried adding some logging statements to your code to determine 
exactly where it is getting stuck?

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-05 Thread Lisandro
Thank you Anthony, yes I'm aware of that.
I use it like that for this reason: sometimes (not very often) an external 
app modifies a field of the auth_user table (specifically, it sets true or 
false a field that I use as a flag). However that change isn't updated to 
auth.user. In order to do so, the user needs to logout and login again. So 
I retrieve the auth_user record again and store it to response.answer.

Maybe it could be done like this:
if auth.is_logged_in():
auth.user = db.auth_user[auth.user.id]

But I thought it could be break something with Auth methods, so I store it 
in response.user.

Anyway, I set this topic as "no action needed" because I opened a new 
topic, I've found some more info and I think the issue isn't related to 
that sentence. In fact, if it was related to that sentence, the problem 
would trigger with every user account. Today we just had two more of those 
cases. This is the new topic I posted:
https://groups.google.com/forum/#!topic/web2py/E9jrmf5E-B4

Regards,
Lisandro.


El jueves, 5 de abril de 2018, 12:55:26 (UTC-3), Anthony escribió:
>
> On Tuesday, April 3, 2018 at 8:43:31 AM UTC-4, Lisandro wrote:
>>
>> I store the sessions in the database, so there is no problem with a 
>> locked file.
>>
>> I've just found something interesting that could help to figure out: when 
>> the problem presents, I checked the pg_stat_activity in postgres to see if 
>> there was a long running query, and there is indeed. But the query is a 
>> simple select to the auth_user table, to select the row of the logged in 
>> user. How can this query take that long? Does web2py lock the user row? If 
>> so, how do I release it?
>>
>> Something to consider: in my db.py, at the end, I do this:
>>
>> response.user = db.auth_user[auth.user.id] if auth.is_logged_in() else 
>> None
>>
>
> FYI, auth.user is the user's record from db.auth_user (minus the password 
> field and the update_record and delete_record attributes), so depending on 
> what you are doing with response.user, you might be able to replace the 
> above with:
>
> response.user = auth.user
>
> Or just use auth.user directly in your code.
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-05 Thread Anthony
On Tuesday, April 3, 2018 at 8:43:31 AM UTC-4, Lisandro wrote:
>
> I store the sessions in the database, so there is no problem with a locked 
> file.
>
> I've just found something interesting that could help to figure out: when 
> the problem presents, I checked the pg_stat_activity in postgres to see if 
> there was a long running query, and there is indeed. But the query is a 
> simple select to the auth_user table, to select the row of the logged in 
> user. How can this query take that long? Does web2py lock the user row? If 
> so, how do I release it?
>
> Something to consider: in my db.py, at the end, I do this:
>
> response.user = db.auth_user[auth.user.id] if auth.is_logged_in() else 
> None
>

FYI, auth.user is the user's record from db.auth_user (minus the password 
field and the update_record and delete_record attributes), so depending on 
what you are doing with response.user, you might be able to replace the 
above with:

response.user = auth.user

Or just use auth.user directly in your code.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-03 Thread Lisandro
I store the sessions in the database, so there is no problem with a locked 
file.

I've just found something interesting that could help to figure out: when 
the problem presents, I checked the pg_stat_activity in postgres to see if 
there was a long running query, and there is indeed. But the query is a 
simple select to the auth_user table, to select the row of the logged in 
user. How can this query take that long? Does web2py lock the user row? If 
so, how do I release it?

Something to consider: in my db.py, at the end, I do this:

response.user = db.auth_user[auth.user.id] if auth.is_logged_in() else None


I think that is the query taking that long, because this is the SQL query 
that I can see in the pg_stat_activity:

SELECT  auth_user.id, auth_user.first_name, auth_user.last_name, auth_user.
email, auth_user.password, auth_user.registration_key, auth_user.
reset_password_key, auth_user.registration_id, auth_user.alta, auth_user.
plantel, auth_user.responsable, auth_user.nombre, auth_user.telefono, 
auth_user.autor, auth_user.foto, auth_user.foto_temp, auth_user.moderador, 
auth_user.descripcion, auth_user.facebook, auth_user.twitter, auth_user.
linkedin, auth_user.gplus FROM auth_user WHERE (auth_user.id = 2) LIMIT 1 
OFFSET 0;


So, I think the problem is related to that sentence where I need to 
retrieve the row of the logged in user and store it in a variable inside 
response object.
What do you think?



El martes, 3 de abril de 2018, 8:29:09 (UTC-3), Leonel Câmara escribió:
>
> I would use redis for sessions instead of the default file based ones, it 
> makes the site a lot quicker and it would probably solve your problem as I 
> would bet this is happening due to a locked session file.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Request with login privileges hangs for a specific user account, how to debug it?

2018-04-03 Thread Leonel Câmara
I would use redis for sessions instead of the default file based ones, it 
makes the site a lot quicker and it would probably solve your problem as I 
would bet this is happening due to a locked session file.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.