mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > PrimeNet

Reply
 
Thread Tools
Old 2017-02-02, 07:09   #1189
Madpoo
Serpentine Vermin Jar
 
Madpoo's Avatar
 
Jul 2014

1100110010102 Posts
Default

Quote:
Originally Posted by snme2pm1 View Post
My recollection is that you introduced 7 days, from a former 48 hours.
Dadgumit... I'd written this reply about the differences between the PHP session timeout and the cookie expiration...I thought I knew what PHP was doing.

But, I did some testing and even though there's a lovely GIMPSWWW cookie value being set, when I logout it's still there, and logging back in doesn't cause the server to do a set-cookie like I thought. So, it probably is using those pesky PHP session files after all. Curses.

I'll have to explore some more and see what's up. I'm spoiled at my day job...there are people who figure that sort of thing out for me (and we don't use PHP, fortunately).

Last fiddled with by Madpoo on 2017-02-02 at 07:43
Madpoo is offline   Reply With Quote
Old 2017-02-02, 07:56   #1190
Madpoo
Serpentine Vermin Jar
 
Madpoo's Avatar
 
Jul 2014

327410 Posts
Default

Quote:
Originally Posted by Madpoo View Post
Dadgumit... I'd written this reply about the differences between the PHP session timeout and the cookie expiration...I thought I knew what PHP was doing.

But, I did some testing and even though there's a lovely GIMPSWWW cookie value being set, when I logout it's still there, and logging back in doesn't cause the server to do a set-cookie like I thought. So, it probably is using those pesky PHP session files after all. Curses.

I'll have to explore some more and see what's up. I'm spoiled at my day job...there are people who figure that sort of thing out for me (and we don't use PHP, fortunately).
If I delete the cookie and login again, it does a set-cookie like this:
Code:
Set-Cookie: GIMPSWWW=<encoded string>; expires=Thu, 09-Feb-2017 07:44:40 GMT; Max-Age=604800; path=/; domain=mersenne.org
So it does set the cookie timeout like I thought, 7 days (604,800 seconds).

That encoded string actually hashes it to the PHP session file which has the info that the server references (user id, team id, etc). The data is actually JSON...I honestly didn't know what format it would be; I didn't expect JSON, but whatever.

See, I'm used to systems where the cookie might hold a token that was generated using a static key, and that token is your passport, there doesn't need to be anything stored on the server.

In one sense, it's nice because that file has some frequently used info, like your team/user id which the various web pages can use to quickly reference. The downside is that PHP on Windows throws all those files into a single directory. I don't know how much any of y'all know about Windows file systems (FAT32 or NTFS, either way) but let's just say putting 500K-600K files into a single directory is a nightmare for performance.

Fortunately if the system is looking for a particular file, it loads fast, no worries. But if you're doing any kind of bulk file management, forget about it. I should explore if PHP has any kind of option for multi-level support for those. 2K-5K files per directory is really about optimal for that. Any more and it just bogs down.

Last fiddled with by Madpoo on 2017-02-02 at 08:02
Madpoo is offline   Reply With Quote
Old 2017-02-02, 15:23   #1191
Mark Rose
 
Mark Rose's Avatar
 
"/X\(‘-‘)/X\"
Jan 2013

32×317 Posts
Default

Look into the set_session_save_handler function of PHP. A common practice is to store sessions in a database. Update a last-used field every hour or so (check in the write handler if it's been an hour if there are no other data changes), then run a scheduled task to delete sessions where last-used is a month old or whatever.
Mark Rose is offline   Reply With Quote
Old 2017-02-02, 15:55   #1192
Madpoo
Serpentine Vermin Jar
 
Madpoo's Avatar
 
Jul 2014

CCA16 Posts
Default

Quote:
Originally Posted by Mark Rose View Post
Look into the set_session_save_handler function of PHP. A common practice is to store sessions in a database. Update a last-used field every hour or so (check in the write handler if it's been an hour if there are no other data changes), then run a scheduled task to delete sessions where last-used is a month old or whatever.
I'll take a look at that.

One huge problem I realized is that PHP will create a session file for each connection that didn't already have that cookie value in the request header.

All well and good until it occurred to me that the server is generating in excess of 70-80K files on a daily basis, and that is probably because the site gets activity from crawlers that don't have a cookie already and sure as heck won't be setting one to use on their next page request.

I don't know if there is any good reason for a session file for an anonymous user, and in fact most of them are zero bytes.

What I'd like to find is a method to have it only bother with session files and setting a cookie if the user logs in, but that's another place where I don't know enough about PHP to know if that's possible, or if it's just a server wide deal. I know how I could set *session* cookies (temporal) in a .NET scenario with page directives, and a user cookie is pretty easy to manage, so hopefully that all translates into something PHP'ish.
Madpoo is offline   Reply With Quote
Old 2017-02-02, 17:17   #1193
Mark Rose
 
Mark Rose's Avatar
 
"/X\(‘-‘)/X\"
Jan 2013

32×317 Posts
Default

Yeah, in php.ini, set session.auto_start to 0 (which is the default). You'll have to modify the PHP code to detect if a session cookie is present and at that point call session_start appropriately.
Mark Rose is offline   Reply With Quote
Old 2017-02-02, 20:19   #1194
Madpoo
Serpentine Vermin Jar
 
Madpoo's Avatar
 
Jul 2014

2·1,637 Posts
Default

Quote:
Originally Posted by Mark Rose View Post
Yeah, in php.ini, set session.auto_start to 0 (which is the default). You'll have to modify the PHP code to detect if a session cookie is present and at that point call session_start appropriately.
I'll have to test that.

For now, I found the part about using "N;<path>" to set the session path, where N is the # of subdirectory levels. I set it to 1 for now and moved all existing files (had to stop the web server temporarily while moving them).

I also modified my custom cleanup task (the PHP garbage collector never seemed to run) to not only clean out stuff older than the expiration, but also to nuke any zero-byte sessions. That'll tide me over until I can see how to keep sessions from being created until/unless there's a login.

One final change was to modify the cookie expiration to 30 days instead of 7.

I learned a lot of PHP cookies and sessions.
Madpoo is offline   Reply With Quote
Old 2017-02-27, 14:03   #1195
ramgeis
 
ramgeis's Avatar
 
Apr 2013

22×29 Posts
Default

When I look at the detailed stats page for my account I see in the workload section at the bottom of the page this message:

Quote:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Arithmetic overflow error converting expression to data type int., SQL state 22003 in SQLExecDirect in C:\inetpub\www\account\default.php on line 316 Warning: odbc_fetch_array() expects parameter 1 to be resource, boolean given in C:\inetpub\www\account\default.php on line 321
and the assignment summary by work-type table is empty. This is what I see most of the time. It happens now and then that this message doesn't show up and the table contains the right values.
ramgeis is offline   Reply With Quote
Old 2017-02-27, 16:23   #1196
marigonzes
 
Feb 2017

D16 Posts
Default

If I go to https://www.mersenne.org/cpus/ while logged in, check the "I am sure I know what I am doing" checkbox and then click either "Merge checked CPUs" or "Drop checked CPUs", I get the following error:

Quote:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'., SQL state 37000 in SQLExecDirect in C:\inetpub\www\cpus\default.php on line 97 Warning: odbc_fetch_array() expects parameter 1 to be resource, boolean given in C:\inetpub\www\cpus\default.php on line 98
marigonzes is offline   Reply With Quote
Old 2017-02-27, 16:42   #1197
Madpoo
Serpentine Vermin Jar
 
Madpoo's Avatar
 
Jul 2014

CCA16 Posts
Default

Quote:
Originally Posted by marigonzes View Post
If I go to https://www.mersenne.org/cpus/ while logged in, check the "I am sure I know what I am doing" checkbox and then click either "Merge checked CPUs" or "Drop checked CPUs", I get the following error:
Aren't you all glad we helpfully display the PHP errors to the end user? LOL

(well, it's ugly, but on the bright side it helps us figure out what's what without digging through the PHP error log and trying to match that up with whatever the user was trying to do at the time).

In both of the recent posts I think SQL is returning a null where a value was expected and PHP complained. When I have time (or if James or George sees this and gets to it first?) I can take a look. I went through last weekend and squashed a few things that were throwing errors more consistently but I knew there were some others that needed investigating.
Madpoo is offline   Reply With Quote
Old 2017-02-27, 19:42   #1198
marigonzes
 
Feb 2017

13 Posts
Default

Just found another issue:

If I type a wrong Username/Password combination, the site takes me to a 404 page.
marigonzes is offline   Reply With Quote
Old 2017-02-27, 22:41   #1199
Madpoo
Serpentine Vermin Jar
 
Madpoo's Avatar
 
Jul 2014

2×1,637 Posts
Default

Quote:
Originally Posted by ramgeis View Post
When I look at the detailed stats page for my account I see in the workload section at the bottom of the page this message:



and the assignment summary by work-type table is empty. This is what I see most of the time. It happens now and then that this message doesn't show up and the table contains the right values.
I have every reason to believe your issue is due to your unique circumstances.

You have 2 cpus with assignments... one of them only has 4 active assignments while the other has 710,618 assignments.

Part of that little table does an average age of all your assignments which it does by using the SQL avg() function for the difference in minutes between date assigned and now, divided by 1440.0 (to show the average diff in days to a precision of x.xx).

Your particular issue is that it's easily overflowing the ability of SQL to average an int over that many rows (int is the default cast for datediff, I'm guessing).

I'm questioning the usefulness of showing the average assignment age for that many (or even at all). It seems of questionable utility...

I could cast the datediff to bigint before inside avg() ... your average TF assignment age (of which there are 710,606 right now) is 36.88 days. Does that help you in any way? LOL
Madpoo is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Official "Faits erronés dans de belles-lettres" thread ewmayer Lounge 39 2015-05-19 01:08
Official "all-Greek-to-me Fiction Literature and Cinema" Thread ewmayer Science & Technology 41 2014-04-16 11:54
Official "Lasciate ogne speranza" whinge-thread cheesehead Soap Box 56 2013-06-29 01:42
Official "Ernst is a deceiving bully and George is a meanie" thread cheesehead Soap Box 61 2013-06-11 04:30
Official "String copy Statement Considered Harmful" thread Dubslow Programming 19 2012-05-31 17:49

All times are UTC. The time now is 02:57.

Sat Sep 19 02:57:39 UTC 2020 up 9 days, 8 mins, 0 users, load averages: 0.98, 1.05, 1.08

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.