Skip to content

Previous ALTER statement doesn't persist within next aurora_data_api context manager instance #48

@marshall7m

Description

@marshall7m

First off thank you for creating an awesome tool for interacting with aurora databases!

Problem

Setting the current user's search path with an aurora data API connection and cursor instance doesn't persist within a separate downstream connection and cursor instance.

The following snippet show this problem:

import aurora_data_api

with aurora_data_api.connect(
    aurora_cluster_arn=cluster_arn,
    secret_arn=secret_arn,
    database=db,
    continue_after_timeout=True,
) as conn:
    with conn.cursor() as cur:
        cur.execute("ALTER ROLE CURRENT_USER SET search_path to bar")

with aurora_data_api.connect(
    aurora_cluster_arn=cluster_arn,
    secret_arn=secret_arn,
    database=db
) as conn:
    with conn.cursor() as cur:
        cur.execute("show search_path")

        print(cur.fetchone())

The print statement outputs the default search path and not the expected bar search path.

The RDS cluster is using a serverless Aurora PostgreSQL engine.

Attempts

  • I thought the problem may be a race condition where the show search_path statement is run before the ALTER ROLE CURRENT_USER SET search_path to bar statement is applied to the database. To check this, I successfully ran the ALTER ROLE statement, waited ~30 minutes, and ran the subsequent show search path statement. The search path is still not the expected value.

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