FAQ
I'm trying to use database/sql with gocql, a driver for cassandra in an app
that has hundreds of concurrent goroutines and connections. What I'm
observing is a very high rate of having connections with prepared
statements being stolen by other goroutines. Much of my code uses
db.Query(), which internally does a db.Prepare() followed by a stmt.Query,
but (by adding debug code) I observe that when the stmt.Query tries to use
the connection with the prepared statement it has actually been stolen by a
different goroutine and the statement has to be re-prepared. Specifically,
I see it hitting the "if !match" case in stmt.connStmt() very frequently.
What is the purpose of releasing the connection with the prepared statement
to the pool in the first place?

--

Search Discussions

  • Tamás Gulácsi at Dec 31, 2012 at 11:25 am
    I've just stepped on this while trying to write a
    github.com/bradfitz/go-sql-test -compatible Oracle driver
    (github.com/tgulacsi/go-sql-test).
    It seems to me it Always creates a new cursor and prepared statement for
    mi, in a tight loop (without concurrency!).


    Dear Brad,

    Can you help us? I've always had troubles figuring out when is a connection
    free (free from running cursors)...

    GThomas

    --
  • Brad Fitzpatrick at Dec 31, 2012 at 7:16 pm
    I'm on vacation until the 7th, and then I'll try to get caught up with
    database/sql patches and questions.
    On Mon, Dec 31, 2012 at 3:24 AM, Tamás Gulácsi wrote:

    I've just stepped on this while trying to write a
    github.com/bradfitz/go-sql-test -compatible Oracle driver (
    github.com/tgulacsi/go-sql-test).
    It seems to me it Always creates a new cursor and prepared statement for
    mi, in a tight loop (without concurrency!).


    Dear Brad,

    Can you help us? I've always had troubles figuring out when is a
    connection free (free from running cursors)...

    GThomas

    --

    --
  • Edward Chen92 at Dec 17, 2015 at 3:43 pm
    Was this ever answered? I'm curious as well!
    On Monday, December 31, 2012 at 2:16:06 PM UTC-5, bradfitz wrote:

    I'm on vacation until the 7th, and then I'll try to get caught up with
    database/sql patches and questions.

    On Mon, Dec 31, 2012 at 3:24 AM, Tamás Gulácsi <tgula...@gmail.com
    <javascript:>> wrote:
    I've just stepped on this while trying to write a
    github.com/bradfitz/go-sql-test -compatible Oracle driver (
    github.com/tgulacsi/go-sql-test).
    It seems to me it Always creates a new cursor and prepared statement for
    mi, in a tight loop (without concurrency!).


    Dear Brad,

    Can you help us? I've always had troubles figuring out when is a
    connection free (free from running cursors)...

    GThomas

    --

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Gulácsi Tamás at Dec 17, 2015 at 11:12 am
    I don't remember exactly, but now I know that database/sql's QueryRow
    closes the statement/cursor right after the execution.

    <edward.chen92@gmail.com> ezt írta (időpont: 2015. dec. 17., Cs 12:03):
    Was this ever answered? I'm curious as well!
    On Monday, December 31, 2012 at 2:16:06 PM UTC-5, bradfitz wrote:

    I'm on vacation until the 7th, and then I'll try to get caught up with
    database/sql patches and questions.

    On Mon, Dec 31, 2012 at 3:24 AM, Tamás Gulácsi <tgula...@gmail.com>
    wrote:
    I've just stepped on this while trying to write a
    github.com/bradfitz/go-sql-test -compatible Oracle driver (
    github.com/tgulacsi/go-sql-test).
    It seems to me it Always creates a new cursor and prepared statement for
    mi, in a tight loop (without concurrency!).


    Dear Brad,

    Can you help us? I've always had troubles figuring out when is a
    connection free (free from running cursors)...

    GThomas

    --

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Nirbhay Choubey at Dec 21, 2015 at 1:25 am

    On Thursday, December 17, 2015 at 6:13:11 AM UTC-5, Tamás Gulácsi wrote:
    I don't remember exactly, but now I know that database/sql's QueryRow
    closes the statement/cursor right after the execution.
    The statement (PS) remains open until either statement or connection is
    closed.

    -- Nirbhay

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Brad Fitzpatrick at Feb 1, 2016 at 11:48 pm
    Sorry, Tamás, I just found this email again. If this is still a problem,
    please open an issue.

    On Mon, Dec 31, 2012 at 3:24 AM, Tamás Gulácsi wrote:

    I've just stepped on this while trying to write a
    github.com/bradfitz/go-sql-test -compatible Oracle driver (
    github.com/tgulacsi/go-sql-test).
    It seems to me it Always creates a new cursor and prepared statement for
    mi, in a tight loop (without concurrency!).


    Dear Brad,

    Can you help us? I've always had troubles figuring out when is a
    connection free (free from running cursors)...

    GThomas

    --

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Gulácsi Tamás at Feb 2, 2016 at 4:56 am
    Not a problem. Will do if occurs again.

    Brad Fitzpatrick <bradfitz@golang.org> ezt írta (időpont: 2016. febr. 2., K
    0:48):
    Sorry, Tamás, I just found this email again. If this is still a problem,
    please open an issue.

    On Mon, Dec 31, 2012 at 3:24 AM, Tamás Gulácsi wrote:

    I've just stepped on this while trying to write a
    github.com/bradfitz/go-sql-test -compatible Oracle driver (
    github.com/tgulacsi/go-sql-test).
    It seems to me it Always creates a new cursor and prepared statement for
    mi, in a tight loop (without concurrency!).


    Dear Brad,

    Can you help us? I've always had troubles figuring out when is a
    connection free (free from running cursors)...

    GThomas

    --

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 30, '12 at 2:52a
activeFeb 2, '16 at 4:56a
posts8
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase