Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requests to AWS S3 hang with HTTP.jl v0.9.15 #772

Closed
nickrobinson251 opened this issue Sep 28, 2021 · 9 comments · Fixed by JuliaCloud/AWS.jl#467 or #773
Closed

Requests to AWS S3 hang with HTTP.jl v0.9.15 #772

nickrobinson251 opened this issue Sep 28, 2021 · 9 comments · Fixed by JuliaCloud/AWS.jl#467 or #773

Comments

@nickrobinson251
Copy link
Collaborator

With [email protected], i'm seeing GET requests to S3 hang indefinitely.

The actual behaviour i am seeing is using AWSS3.jl v0.9.2 (example at JuliaCloud/AWSS3.jl#215), but the behaviour is only present when using HTTP v0.9.15.

I haven't quite narrowed down what's going on... but here's a bit of thinking out loud:

Looking at the 0.9.15 changes (v0.9.14...v0.9.15) i'd guess the most related change might be #752 ?

Needs further investigation :)

@fredrikekre
Copy link
Member

Most likely yea, does it work again if you close the response stream as suggested in the CHANGELOG? Might have been a too breaking change to put in a feature release.

@fredrikekre
Copy link
Member

Fortunately you can call close multiple times so if you add that it should be compatible with old HTTP.jl still.

@pfitzseb
Copy link
Contributor

#517 is very similar.

@nickrobinson251
Copy link
Collaborator Author

does it work again if you close the response stream

i'll give it a go :)

it didn't fix it on my first attempt, but i'm not too familiar with the AWS code so might need to add a close call in multiple places -- taking a look now.

@oxinabox
Copy link
Member

oxinabox commented Sep 28, 2021

I would guess what is happening is that somewhere in the code for AWS / AWSS3
something was calling some other function that will keep reading until it encounters a EOF, and will block if it gets to the end of the steam without hitting the end of file. (Which is a feature of some read commands, that might be used on IOSteams where things trickle in slowly).
And since HTTP.jl was, after #752, no longer closing the stream, it was now hanging waiting for a closing of the steam that would never come.

This makes me think that #752 was not the right solution to #543
If we know the data is done arriving, we should be closing the stream in HTTP.
But i guess not having Base.closewrite means it is impossible to indicate that writing is done without also preventing reading.

It might still be better as a hack to close all streams except IOBuffer or something like that?
Until we have closewrite?
cc @c42f

bors bot added a commit to JuliaCloud/AWS.jl that referenced this issue Sep 28, 2021
467: Always close the `response_stream` after `HTTP.request` r=mattBrzezinski a=nickrobinson251

- We need to explicitly close the `response_stream`
  (`HTTP.request` no longer closes it for us)
  in HTTP.jl v0.9.15+ (see JuliaWeb/HTTP.jl#752)
- Since `close` is safe to call multiple times,
  this should be compatible with old HTTP.jl versions. 
- Should fix issue #466 (and JuliaCloud/AWSS3.jl#215)
- Also since we're fixing this here, we can close JuliaWeb/HTTP.jl#772

~TODO: add test... i just need to recreate the issue using AWS.jl explicitly (rather than AWSS3)~ done.

Co-authored-by: Nick Robinson <[email protected]>
Co-authored-by: Nick Robinson <[email protected]>
bors bot added a commit to JuliaCloud/AWS.jl that referenced this issue Sep 28, 2021
467: Always close the `response_stream` after `HTTP.request` r=mattBrzezinski a=nickrobinson251

- We need to explicitly close the `response_stream`
  (`HTTP.request` no longer closes it for us)
  in HTTP.jl v0.9.15+ (see JuliaWeb/HTTP.jl#752)
- Since `close` is safe to call multiple times,
  this should be compatible with old HTTP.jl versions. 
- Should fix issue #466 (and JuliaCloud/AWSS3.jl#215)
- Also since we're fixing this here, we can close JuliaWeb/HTTP.jl#772

~TODO: add test... i just need to recreate the issue using AWS.jl explicitly (rather than AWSS3)~ done.

Co-authored-by: Nick Robinson <[email protected]>
Co-authored-by: Nick Robinson <[email protected]>
@omus
Copy link
Contributor

omus commented Sep 28, 2021

It should be pointed out that using response_stream for HTTP.jl 0.9.14 and below only really worked (I believe) with the unexported Base.BufferStream. The implementation of this stream seems to require the it be be closed in order for it to be read from. Most streams don't work this way.

I think the general rule should be that you shouldn't close IO instances that you didn't create.

@fredrikekre
Copy link
Member

But read would still block, e.g. this code now hangs:

using HTTP, SimpleBufferStream, SHA
bs = BufferStream()
HTTP.get("https://julialang.org"; response_stream=bs)
SHA.sha256(bs)

I think the general rule should be that you shouldn't close IO instances that you didn't create.

Yea, this makes sense, but perhaps it was a bit too optimistic to put this in a feature release.

@fredrikekre
Copy link
Member

fredrikekre commented Sep 29, 2021

I propose we revert the #752 change: #773. In addition to breaking AWS it also breaks tests for SimpleBufferStreams and TeeStreams for example.

@omus
Copy link
Contributor

omus commented Sep 29, 2021

I propose we revert the #752 change: #773. In addition to breaking AWS it also breaks tests for SimpleBufferStreams and TeeStreams for example.

We should make a follow up issue to remove the close call in a breaking release (1.0.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants