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

Connection already has associated data reader guard missing #59

Open
MaceWindu opened this issue Jun 18, 2022 · 3 comments
Open

Connection already has associated data reader guard missing #59

MaceWindu opened this issue Jun 18, 2022 · 3 comments
Assignees

Comments

@MaceWindu
Copy link
Contributor

I've been testing handling of multiple open queries per single connection functionality for provider and discovered that provider hangs instead of one of two options:

  1. executing second query (I suspect ClickHouse TCP protocol doesn't support it)
  2. throwing guard exception if it is not supported by protocol/provider

Repro:

using var cn = new ClickHouseConnection(cs);
cn.Open();

using var cmd1 = cn.CreateCommand();
cmd1.CommandText = "select * from system.tables";
using var rd1 = cmd1.ExecuteReader();

using var cmd2 = cn.CreateCommand();
cmd2.CommandText = "select * from system.tables";
// hangs here in ClickHouseTcpClient.OpenSession() call
using var rd2 = cmd2.ExecuteReader();
System.Private.CoreLib.dll!System.Threading.Monitor.Wait(object obj, int millisecondsTimeout)
System.Private.CoreLib.dll!System.Threading.SemaphoreSlim.WaitUntilCountOrTimeout(int millisecondsTimeout, uint startTime, System.Threading.CancellationToken cancellationToken)
System.Private.CoreLib.dll!System.Threading.SemaphoreSlim.Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken)
Octonica.ClickHouseClient.dll!Octonica.ClickHouseClient.ClickHouseTcpClient.OpenSession(bool async, Octonica.ClickHouseClient.IClickHouseSessionExternalResources externalResources, System.Threading.CancellationToken sessionCancellationToken, System.Threading.CancellationToken cancellationToken)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Octonica.ClickHouseClient.ClickHouseTcpClient.<OpenSession>d__15>(ref Octonica.ClickHouseClient.ClickHouseTcpClient.<OpenSession>d__15 stateMachine)
Octonica.ClickHouseClient.dll!Octonica.ClickHouseClient.ClickHouseCommand.OpenSession(bool closeConnection, bool async, System.Threading.CancellationToken cancellationToken)
Octonica.ClickHouseClient.dll!Octonica.ClickHouseClient.ClickHouseCommand.ExecuteDbDataReader(System.Data.CommandBehavior behavior, bool ignoreProfileEvents, bool async, System.Threading.CancellationToken cancellationToken)
System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<Octonica.ClickHouseClient.ClickHouseCommand.<ExecuteDbDataReader>d__83>(ref Octonica.ClickHouseClient.ClickHouseCommand.<ExecuteDbDataReader>d__83 stateMachine)
Octonica.ClickHouseClient.dll!Octonica.ClickHouseClient.ClickHouseCommand.ExecuteReader()
@SergeyMirvoda
Copy link
Contributor

Thank you for the report, we are on vacation)

Will fix this and other issues on next week.

@SergeyMirvoda
Copy link
Contributor

SergeyMirvoda commented Mar 16, 2024

Hm, looks like it is or beloved MARS feature from MS SQL server.
I doubt CH supports this, even in npgsql it is still "in progress" npgsql/npgsql#462
@victor-sushko can we throw exception something like "OperationInProgressException: A command is already in progress"

@MaceWindu
Copy link
Contributor Author

Exception is fine as far as it doesn't hang like it does now.

BTW, npgsql (and also mysql) are actually exceptions here - most of databases we test support multiple queries over one connection.

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

No branches or pull requests

3 participants