Register FAQ Search Today's Posts Mark Forums Read

2017-02-02, 07:09   #1189
Serpentine Vermin Jar

Jul 2014

2·1,637 Posts

Quote:
 Originally Posted by snme2pm1 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

2017-02-02, 07:56   #1190
Serpentine Vermin Jar

Jul 2014

CCA16 Posts

Quote:
 Originally Posted by Madpoo 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).
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

 2017-02-02, 15:23 #1191 Mark Rose     "/X\(‘-‘)/X\" Jan 2013 23×3×7×17 Posts 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.
2017-02-02, 15:55   #1192
Serpentine Vermin Jar

Jul 2014

2×1,637 Posts

Quote:
 Originally Posted by Mark Rose 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.

 2017-02-02, 17:17 #1193 Mark Rose     "/X\(‘-‘)/X\" Jan 2013 23×3×7×17 Posts 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.
2017-02-02, 20:19   #1194
Serpentine Vermin Jar

Jul 2014

CCA16 Posts

Quote:
 Originally Posted by Mark Rose 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.

2017-02-27, 14:03   #1195
ramgeis

Apr 2013

11610 Posts

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.

2017-02-27, 16:23   #1196
marigonzes

Feb 2017

13 Posts

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

2017-02-27, 16:42   #1197
Serpentine Vermin Jar

Jul 2014

2×1,637 Posts

Quote:
 Originally Posted by marigonzes 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.

 2017-02-27, 19:42 #1198 marigonzes   Feb 2017 13 Posts Just found another issue: If I type a wrong Username/Password combination, the site takes me to a 404 page.
2017-02-27, 22:41   #1199
Serpentine Vermin Jar

Jul 2014

2·1,637 Posts

Quote:
 Originally Posted by ramgeis 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

 Similar Threads Thread Thread Starter Forum Replies Last Post ewmayer Lounge 39 2015-05-19 01:08 ewmayer Science & Technology 41 2014-04-16 11:54 cheesehead Soap Box 56 2013-06-29 01:42 cheesehead Soap Box 61 2013-06-11 04:30 Dubslow Programming 19 2012-05-31 17:49

All times are UTC. The time now is 18:41.

Tue Sep 22 18:41:36 UTC 2020 up 12 days, 15:52, 1 user, load averages: 1.76, 1.86, 1.92