Intermittent timing race with event poller
animats Resident
There are some delicate relationships between the event poller server side timeout, the event poller viewer side timeout and the child agent inactivity server side timeout. Problems in this area have been discovered before. I think I just got to the bottom of another one.
This is not something that needs an urgent fix, but if any work is done on the event poller, this issue needs to be considered.
Pepper Linden has told me that there's a 50-secoind timer which causes the server to disconnect a child agent for inactivity. I've seen that happening. If the viewer's long poll timeout is longer than 50 seconds, there is a possibiilty of child agents timing out and a DisableSimulator being sent.
I've done some tests in Sharpview. A 90 second timeout causes an unexpected DisableSimulator for an active child region followed by a viewer disconnect about once every hour. With a 15 second timeout, that does not happen in 24 hours. So I now have a workaround inside Sharpview.
Here is what I think is happening. I can only see viewer side, of course.
Pepper set up an island atop a region corner at Blake Sea - Nelson on aditi. I set up a train track loop which goes right through the region corner, and a small train which endlessly circles the loop. We put avatars on the train and run unattended region crossing tests for hours or days. This is a useful stress test and has brought out some region crossing bugs, which have been fixed. By now, the LL and Firestorm viewers can run that test for a full day without error.
But when I run one of the avatars from my Sharpview viewer, it was failing in 1-3 hours. I was using a long HTTPS poll with a 90 second timeout. That works fine until you start running multi-hour tests.
Why would the timeout matter? Because, apparently, no activity on the event channel for 50 seconds causes a DisableSimulator. An event channel timeout seems to count as "activity". So if the event channel timeout is longer than the DisableSimulator timeout, and there's no real traffic on the event channel, and it's a child region, and the timers line up, the region disables itself for that viewer for inactivity.
Henri Beauchamp has experimented with various timeouts in his viewer, and notes that behavior changes with the timeout value. Since both server and viewer can time out, whomeever has the shorter timeout times out first. If both have the same timeout, there's a race. We're still not sure about all the possible race conditions.
I'd suggest a solid fix that gets rid of HTTPS timeouts. When there are no events to send, the servers should send an empty array of events over the event channel every 15-20 seconds to keep the connection alive. Existing viewers should ignore such an empty array. so this should not affect existing viewers.
All HTTPS transactions on the event channel then become OK 200 transactions, the happy path. Overhead drops, because re-establishing the HTTPS connection several times a minute means a full cryptographic handshake, while sending a short message over an existing persistent connection is much cheaper. If there are any remaining unexplained event poll problems, this is probably worth doing.
It's so easy to create intermittent problems by changing one of those numbers.
Changes to libcurl, Apache (which, I think, front-ends the HTTPS caps on sim servers), the sim servers themselves, or viewers can affect this. It's a huge pain to diagnose such problems, because the failure rate is so low and you need a test fixture like the little train on its track loop. This took weeks of work, because the test is so slow.
Log In
Henri Beauchamp
FYI, for quite a while now, I have been using a custom (and configurable) viewer-side timeout in the Cool VL Viewer for SL, which default at 25 seconds (i.e. below all the timeouts I could observe occurring outside of the viewer itself before that change, the shorter I could find being a 30s timeout by libcurl).
For OpenSim, I have a different setting defaulting at 90s (the former hard-coded value), since OpenSim is not impacted by those pesky server-side timeouts and the resulting race conditions on reconnect.
I also have a workaround implemented for race conditions occurring when a TP is requested by the user just as the event queue connection times out. The TP request is queued, and if too close to the 25s timeout to have a chance to complete, a new event queue is kicked up with the server, causing the latter to drop the previous one; the queued TP request is then sent once the new connection established and safe.
Monty Brandenberg
Okay, have a lead-off topic here: https://community.secondlife.com/forums/topic/535260-eventqueueget-problems-pitfalls-and-potential-improvements/
animats Resident
Just heard from Henri Beauchamp (CoolVL viewer). He discovered independently that a viewer-side timeout of 20 seconds works well, and that much longer timeouts don't. I'm using 15 seconds.
Monty Brandenberg
Since 'feedback' is a terrible place for design discussions, should we link and bounce over to the forums for something persistent? (And not a continuation of the very long preceding topics.) Some of the information above needs correction, other bits are being incorporated into a EventQueueGetV2 effort. And that should be an open discussion.
animats Resident
Monty Brandenberg Sure, wherever you think it best to talk about this. Please start a topic in an appropriate place. Thanks.