Skip to content

GetObject on large object (~3gb) #715

Closed

Description

@crusader-mike

x64, Windows 7, MSVC 2015, nuget

GetObject on any sufficiently large object succeeds (with no complains in logs on max level) but GetBody().read() returns false. To my surprise GetObject apparently buffers entire response into memory buffer and does not return control to caller until entire object payload is downloaded. And when it rans out of memory -- it silently succeeds, but reading from related iostream fails with no error code or explanations.

  1. What is the point of using iostreams if GetObject result keeps all data in memory? Why not give me direct access to that memory so that I avoid expensive layer of iostream logic?
  2. Is there any way to get smth more meaningful in code and/or logs than simple false from read()?
  3. Why GetObject waits for entire payload to be loaded into memory before returning to caller? You'd expect it to return early and resulting iostream would read data from underlying socket allowing me to avoid buffering entire object in memory.

Activity

  1. crusader-mike commented on Nov 3, 2017

    @crusader-mike
    Author

    Nevermind... I've found AmazonWebServiceRequest::SetResponseStreamFactory() and this:

                    // NOTE: If using an FStream in order to download a file from S3 to a physical file, then we need to specify
                    // the filemode "std::ios_base::out | std::ios_base::in | std::ios_base::trunc" --
                    // If the file transfer fails, then the error stream from the httpRequest is written to the file instead of the
                        // actual file contents.
                    // If this is the case, then the BuildAWSError function assumes it can 'read' the stream in order to read in the
                    // error status and create an AWSError.  If the file is not marked as read/write (or write only), this will fail
                    // and the error status will instead be an XML_PARSE_ERROR error because the BuildAWSError function failed
                    // The 'truncate' is required to ensure that if the file download IS successful, then it can be written to the
                    // FStream (if ::trunc is not specified, then the FStream.write fails for some unknown reason)
    

    So, basically, for me to be able to stream data into my "sink" I need to implement a stream that supports both output and input. In light of this being non-trivial (especially when sink is not a file on local drive) and related problems with request-timeout I simply implemented download as a sequence of GetObject requests that download data piece-by-piece.

  2. added
    guidance
    and removed on Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    guidance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions