Closed Bug 1512264 Opened 6 years ago Closed 5 years ago

WPT WebDriver client does not reuse HTTP connection, causing us to exhaust the ephemeral port range on Windows

Categories

(Testing :: geckodriver, defect, P1)

Version 3
All
Windows
defect

Tracking

(firefox66 fixed)

RESOLVED FIXED
mozilla66
Tracking Status
firefox66 --- fixed

People

(Reporter: ato, Assigned: ato)

References

Details

Attachments

(1 file)

Although the wdspec WebDriver test client specifies the Keep-Alive
header instructing the HTTPD to make the connection persistent, we
don’t actually make use of this as the httplib.HTTPConnection object
is destroyed after each HTTP request attempt.

This causes us to use a lot of client TCP sockets on Windows and
with bug 1511388 we noticed the following in the log:

> [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted

I ran into this problem once in the past but regrettably didn’t
file a bug for it.  I can’t pinpoint exactly what in smaug’s patch
(https://hg.mozilla.org/try/rev/8776fc15b7cd89e19224161a90dd87fa0f723fa5)
caused us to exhaust the available ports specifically on Windows.

We do however know that Windows has a significantly limited ephemeral
port range compared to other systems and that it doesn’t take much
to exhaust it.  It is also likely that httplib has a bug (maybe a
WinSock bug?) that it doesn’t properly close client sockets after
httplib.HTTPConnection is destroyed/goes out of scope.

More generally we want to persist the HTTP connection between calls
to the remote end HTTPD, so fixing this will likely yield somewhat
better performance also on other systems.

I have verified through a try run that the patch fixes the TVw
problem on Windows 10 x86 opt:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=7a67d6140506d1ee09782df142f71e7bccd2acf5&group_state=expanded
Assignee: nobody → ato
Blocks: 1511388
Status: NEW → ASSIGNED
Priority: -- → P1
Whilst we do set the Keep-Alive HTTP header to request the HTTPD to
use a persistent connection, we throw away the httplib.HTTPConnection
object after each request.  This will causes the HTTPD to serve us
a persistent connection, only to throw it away after the first request.

When the connection timeout is reached, httplib closes the connection
for us.  Unfortunately httplib does not reconnect for the next
request, so we need to manually check if the underlying socket
connection to the server is alive.

We check whether the connection has dropped or if it has unread,
buffered data using select() as a poller.  We could use poll() here
on available systems, which might give a theoretical performance
improvement since it gives O(number of file descriptors), but since
we only deal with one connection select() will probably be good enough.
Blocks: 1089326, 1511387
No longer blocks: 1511388
Pushed by atolfsen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ac21c2e0b040
webdriver: reuse http connection in test client; r=jgraham
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/14439 for changes under testing/web-platform/tests
https://hg.mozilla.org/mozilla-central/rev/ac21c2e0b040
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: