Skip to content

api: use simple streaming upload for GetObject() reader.#735

Merged
krishnasrinivas merged 1 commit into
minio:masterfrom
harshavardhana:get-object
Jul 3, 2017
Merged

api: use simple streaming upload for GetObject() reader.#735
krishnasrinivas merged 1 commit into
minio:masterfrom
harshavardhana:get-object

Conversation

@harshavardhana
Copy link
Copy Markdown
Member

This change is needed to avoid the offset based ReadAt()
calls which can occur if using io.SectionReader().

Optimizing this part re-implementing a sectionReader()
based on Seeker() wasn't worth the complexity.

@harshavardhana
Copy link
Copy Markdown
Member Author

PR is updated fixes a bug as well in the streaming signature implementation. Can anyone review @krishnasrinivas @vadmeste ?

for {
n1, err := s.baseReadCloser.Read(s.chunkBuf[s.chunkBufLen:])
if err == nil || err == io.ErrUnexpectedEOF {
// An instance of this general case is that a Reader returning
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could simplify this comment like,

1. n > 0, err is one of io.EOF, io.ErrUnexpectedEOF, nil - nearing end of stream
2. n ==0, err is io.EOF - actual end of stream

@harshavardhana harshavardhana force-pushed the get-object branch 2 times, most recently from ab67b56 to d9ba0cc Compare July 2, 2017 23:21
// Usually we validate `err` first, but in this case
// we are validating n > 0 for the following reasons.
//
// 1. n > 0, err is one of io.EOF, io.ErrUnexpectedEOF, nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But Read() would not return io.ErrUnexpectedEOF, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually you are right it either returns io.EOF or nil. Let me change it.

// It is to indicate that *minio.Object implements io.ReaderAt.
// and such a functionality is used in the subsequent code path.
if isObject(reader) || isReadAt(reader) || isFile(reader) {
if isFile(reader) || !isObject(reader) && isReadAt(reader) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to disable parallel upload of the parts if the src is minio.Object?

Copy link
Copy Markdown
Member Author

@harshavardhana harshavardhana Jul 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct.. since it is not possible to support streaming parallel downloads in current structure for GetObject to PutObject(). It can lead to some complications in the code base.. so it is pushed as a future work to get back to.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead we will add concurrent copy code on the mc side for in multiples of files.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a possibility by implementing io.SectionReader() based on io.ReadSeeker instead of io.ReaderAt. But it is not worth the complexity for now in my opinion.

// We do not have to upload till totalPartsCount.
if err == io.EOF && size < 0 {
break
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we will not be supporting upload if size is -1?

Copy link
Copy Markdown
Member Author

@harshavardhana harshavardhana Jul 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Streaming we never support size == -1, for size == -1 we fall back to regular multipart upload, which never reaches here..

break
}
}
if err != nil && err != io.ErrUnexpectedEOF {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshavardhana there is a reference to io.ErrUnexpectedEOF here as well

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed.. @krishnasrinivas

@harshavardhana harshavardhana force-pushed the get-object branch 2 times, most recently from a445711 to 160c5ea Compare July 3, 2017 04:23
krishnasrinivas
krishnasrinivas previously approved these changes Jul 3, 2017
This change is needed to avoid the offset based ReadAt()
calls which can occur if using io.SectionReader().

Optimizing this part re-implementing a sectionReader()
based on Seeker() wasn't worth the complexity.

This PR also fixes the bug where the streaming signature
was interpreting the Read() error return in a wrong manner.
@harshavardhana
Copy link
Copy Markdown
Member Author

@krishnasrinivas any more reviews ?

@krishnasrinivas krishnasrinivas merged commit b6f4323 into minio:master Jul 3, 2017
@harshavardhana harshavardhana deleted the get-object branch July 3, 2017 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants