Skip to content

Best way to ignore the failover mechanism in a single query? #58

Description

@sofl88

Hello!

First of all, thank you for this project!

pool = PooledDB(
    creator=pymysql,
    maxconnections=8,
    maxcached=5,
    host=#,
    user=#,
    password=#,
    database=#,
    port=#,
    charset='utf8mb4',
    cursorclass=pymysql.cursors.DictCursor,
    autocommit=True,
    reset=False,
    ssl_ca=#
)

...

with pool.connection() as db:
   with db.cursor() as cur:
      cur.execute('SELECT /*+ MAX_EXECUTION_TIME(10000) */ * FROM table')
      rows = cur.fetchall()

I have this query in my script with the max execution time optimizer hint. Now with the failover mechanism from the underlying steady_db, it does one retry itself (?), which may result in a failed execution that take the max execution time doubled (Because it runs and fails after 10seconds twice).

My current workaround works but I'm not sure if there are any side effects I haven't noted yet

with pool.connection() as db:
   with db.cursor() as cur:
      cur._cursor.execute('SELECT /*+ MAX_EXECUTION_TIME(10000) */ * FROM table')
      cur._con._usage += 1
      rows = cur.fetchall()

Dou you have any suggestions here?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions