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

Bug: Async SequentialStream reads do not complete #600

Closed
Wraith2 opened this issue Jun 11, 2020 · 2 comments · Fixed by #603
Closed

Bug: Async SequentialStream reads do not complete #600

Wraith2 opened this issue Jun 11, 2020 · 2 comments · Fixed by #603

Comments

@Wraith2
Copy link
Contributor

Wraith2 commented Jun 11, 2020

Based on the binary read benchmark in #593 (comment) I tried the code below expecting the behaviour to be fast and found that it simply blocks indefinitely.

            using var conn = new SqlConnection(ConnectionString);
            using var cmd = new SqlCommand("SELECT foo FROM data", conn);
            await conn.OpenAsync();
            using var reader = await cmd.ExecuteReaderAsync(
                System.Data.CommandBehavior.SequentialAccess
            );
            await reader.ReadAsync();
            using var stream =  reader.GetStream(0);
            using var memory = new MemoryStream(16 * 1024);

            await stream.CopyToAsync(memory);
            return (int)memory.Length;

This should work but freezes in a task wait after a single read cycle, the second read never completed. If you change it to standard mode it'll work but it does so by fetching the entire field and giving you a reader over the byte[]. So no workaround, this needs fixing if the team agree that it's a bug.

Edit: for clarity the problem is when multiple packets are needed. The current tests read from a single packet and thus do not do a network read.

@cheenamalhotra
Copy link
Member

Thanks @Wraith2

Ack. Yes that does seem like an issue, if you have a proposed fix, let us know if you'd like to create PR, or we will start working on it soon.

@cheenamalhotra
Copy link
Member

Adding note: This issue is not reproducible in NetFx driver (for .NET Framework) so it should be investigated since when this issue has started to occur for .NET Core applications.

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 a pull request may close this issue.

2 participants