Skip to content

Requests seems to either ignore or not notice rare transport errors #4415

@szborows

Description

@szborows

So I was playing around with blockade and small piece of code that was using request library. I was researching something completely different but I have noticed some anomaly that seems to be originated somewhere in the library or libraries it uses. In essence, 1-2% of requests made when blockade disrupts the network end up with status code 200 and no exceptions, but content is only partial.

Blockade is a tool to test various network conditions. It's on GitHub too.

Maybe the bug is in request or maybe it lies somewhere lower. Or maybe it's my configuration that leads to such results. I successfully tried to uncover this bug on several machines (both physical laptops and VMs in the cloud). I asked colleague from my floor to reproduce this and he succeeded. Replacing requests code with urllib.request.urlopen results in exceptions being thrown for these 1-2% of cases.

I'll be glad if someone else can confirm this or let me know that I did something wrong and should go home.

Expected Result

Exception raised.

Actual Result

Exception is not raised. Response content is cut. Following is output from freshly deployed VM in private cloud. Hash starting with e4b is proper one.

INFO | request #33: http://file_server/files/1MB.bin
INFO | request #33: downloaded 1.0MB in 55.45s. code: 200, hsh: e4b7f62da691604a692844e93304de6b
INFO | 172.17.0.1 - - [04/Dec/2017:01:20:16 +0000] "POST /dl HTTP/1.1" 200 0 "-" "curl/7.52.1"
INFO | request #34: http://file_server/files/1MB.bin
INFO | request #34: downloaded 1.0MB in 50.31s. code: 200, hsh: e4b7f62da691604a692844e93304de6b
INFO | 172.17.0.1 - - [04/Dec/2017:01:21:11 +0000] "POST /dl HTTP/1.1" 200 0 "-" "curl/7.52.1"
INFO | request #35: http://file_server/files/1MB.bin
INFO | request #35: downloaded 0.1509552001953125MB in 69.74s. code: 200, hsh: afb64be8e2fe70f73f9d6e37d39478bf
INFO | 172.17.0.1 - - [04/Dec/2017:01:22:25 +0000] "POST /dl HTTP/1.1" 200 0 "-" "curl/7.52.1"
INFO | request #36: http://file_server/files/1MB.bin
INFO | request #36: downloaded 1.0MB in 55.48s. code: 200, hsh: e4b7f62da691604a692844e93304de6b
INFO | 172.17.0.1 - - [04/Dec/2017:01:23:25 +0000] "POST /dl HTTP/1.1" 200 0 "-" "curl/7.52.1"
INFO | request #37: http://file_server/files/1MB.bin
INFO | request #37: downloaded 1.0MB in 62.19s. code: 200, hsh: e4b7f62da691604a692844e93304de6b

Reproduction Steps

  1. Clone my repo: szborows/blockade-example.
  2. Install blockade (I've tested both 0.3.1 and 0.4.0): pip install blockade
  3. Build docker image: ./build and pull nginx: docker pull nginx:1.11-alpine
  4. Start blockade: blockade up. It should confirm with two containers up
  5. I open separate console to see output from backend container in real time: docker logs -f blockadeexample_backend
  6. Customize and run the script. You can disable tcpdump at start etc. To start script execute ./run
  7. If you don't observe any anomalies in the logs after several runs (each does 100 iterations), then try to change 30 in test_flaky to something bigger. On some machines in cloud I needed to increase this to 40 to observe the failure sooner.

System Information

Python version is: 3.6-alpine. Requests version: 2.18.4. Blockade version: 0.4.0.

Edit: Adding detailed info from my local container.

{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.6"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.6.0"
  },
  "platform": {
    "release": "4.8.0-1-amd64",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.18.4"
  },
  "system_ssl": {
    "version": "100020af"
  },
  "urllib3": {
    "version": "1.22"
  },
  "using_pyopenssl": false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions