Skip to main content

How to avoid parallel select-statements in the same sesssion

  • June 28, 2021
  • 3 replies
  • 5 views

joergschaber
Forum|alt.badge.img+2

Hi,

sometimes , we encounter Vertica errors when executing parallel select-queries in the same session. Parallel queries occur, because we use async methods in our C# application using the ADONET64 vertica driver.
Do you have a hint how to best avoid such parallel queries in the same session? Or do we have another problem here?
We use vertica and driver version is v10.0.1-6.
best,
Jörg

3 replies

marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • June 28, 2021

Vertica, at least as of now, is built so that you can only have one query running per session. Each connection handle can prepare, describe and execute exactly one statement handle. I also write client programs (in good old ANSI C in my case) - but, if I need several queries, nested or in parallel, to perform a task, each thread controlling a query acquires its own connection to Vertica. It always served my purpose ...


joergschaber
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • July 1, 2021

We solved the problem by using a mutex, like this:

             _mutex = new Mutex();
            _command.CommandText = "SELECT * FROM " + table;
            _mutex.WaitOne();
            VerticaDataReader reader = _command.ExecuteReader();
            reader.Close();
            _mutex.ReleaseMutex(); 

Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • July 2, 2021

@joergschaber - Thanks for the update!