DarkWanderer / ClickHouse.Client

.NET client for ClickHouse
MIT License
302 stars 58 forks source link

Query with id ... is already running. (QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING) #489

Open SDmitryL opened 6 days ago

SDmitryL commented 6 days ago

When using linq2db with ClickHouseClient in multi-threaded mode, the error "Query with id ... is already running. (QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING)" occurs. In ClickhouseCommand query_id parameter is passed, which is substituted from the previous answer. Workaround - I implement an additional CommandInterceptor:

    internal class ClearQueryIdInterceptor : CommandInterceptor
    {
        public override DbCommand CommandInitialized(CommandEventData eventData, DbCommand command)
        {
            if (command is ClickHouseCommand clickHouseCommand)
            {
                clickHouseCommand.QueryId = null;
            }

            return command;
        }
    }

Please check whether the query_id parameter is really required in ClickHouseCommand.