Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

samples.samples.autocommit_test: test_enable_autocommit_mode failed #282

Description

@flaky-bot

Note: #254 was also for this test, but it was closed more than 10 days ago. So, I didn't mark it flaky.


commit: e990ff7
buildURL: Build Status, Sponge
status: failed

Test output
self = sql = "INSERT INTO Singers (SingerId, FirstName, LastName) VALUES\n (12, 'Melissa', 'Garcia'),\n (13, 'Russell', 'Morales'),\n (14, 'Jacqueline', 'Long'),\n (15, 'Dylan', 'Shaw')"
args = None
def execute(self, sql, args=None):
"""Prepares and executes a Spanner database operation.
:type sql: str
:param sql: A SQL query statement.
:type args: list
:param args: Additional parameters to supplement the SQL query.
"""
if not self.connection:
raise ProgrammingError("Cursor is not connected to the database")
self._raise_if_closed()
self._result_set = None
# Classify whether this is a read-only SQL statement.
try:
classification = parse_utils.classify_stmt(sql)
if classification == parse_utils.STMT_DDL:
self.connection._ddl_statements.append(sql)
return
# For every other operation, we've got to ensure that
# any prior DDL statements were run.
# self._run_prior_DDL_statements()
 self.connection.run_prior_DDL_statements()

../../google/cloud/spanner_dbapi/cursor.py:190:


self = <google.cloud.spanner_dbapi.connection.Connection object at 0x7fd2d9df0dd8>

def run_prior_DDL_statements(self):
self._raise_if_closed()
if self._ddl_statements:
ddl_statements = self._ddl_statements
self._ddl_statements = []
 return self.database.update_ddl(ddl_statements).result()

../../google/cloud/spanner_dbapi/connection.py:281:


self = <google.api_core.operation.Operation object at 0x7fd2d9cd4898>
timeout = None, retry = <google.api_core.retry.Retry object at 0x7fd2da160e80>

def result(self, timeout=None, retry=DEFAULT_RETRY):
"""Get the result of the operation, blocking if necessary.
Args:
timeout (int):
How long (in seconds) to wait for the operation to complete.
If None, wait indefinitely.
Returns:
google.protobuf.Message: The Operation's result.
Raises:
google.api_core.GoogleAPICallError: If the operation errors or if
the timeout is reached before the operation completes.
"""
kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}
self._blocking_poll(timeout=timeout, **kwargs)
if self._exception is not None:
# pylint: disable=raising-bad-type
# Pylint doesn't recognize that this is valid in this case.
 raise self._exception

E google.api_core.exceptions.FailedPrecondition: 400 Duplicate name in schema: Singers.

.nox/py-3-6/lib/python3.6/site-packages/google/api_core/future/polling.py:134: FailedPrecondition

During handling of the above exception, another exception occurred:

capsys = <_pytest.capture.CaptureFixture object at 0x7fd2d9d8aba8>
database = <google.cloud.spanner_v1.database.Database object at 0x7fd2d9d5b5f8>

@RetryErrors(exception=Aborted, max_tries=2)
def test_enable_autocommit_mode(capsys, database):
connection = connect(INSTANCE_ID, DATABASE_ID)
cursor = connection.cursor()
with mock.patch(
"google.cloud.spanner_dbapi.connection.Cursor", return_value=cursor,
):
 autocommit.enable_autocommit_mode(INSTANCE_ID, DATABASE_ID)

autocommit_test.py:62:


autocommit.py:36: in enable_autocommit_mode
(15, 'Dylan', 'Shaw')"""


self = <google.cloud.spanner_dbapi.cursor.Cursor object at 0x7fd2d9cb0d68>
sql = "INSERT INTO Singers (SingerId, FirstName, LastName) VALUES\n (12, 'Melissa', 'Garcia'),\n (13, 'Russell', 'Morales'),\n (14, 'Jacqueline', 'Long'),\n (15, 'Dylan', 'Shaw')"
args = None

def execute(self, sql, args=None):
"""Prepares and executes a Spanner database operation.
:type sql: str
:param sql: A SQL query statement.
:type args: list
:param args: Additional parameters to supplement the SQL query.
"""
if not self.connection:
raise ProgrammingError("Cursor is not connected to the database")
self._raise_if_closed()
self._result_set = None
# Classify whether this is a read-only SQL statement.
try:
classification = parse_utils.classify_stmt(sql)
if classification == parse_utils.STMT_DDL:
self.connection._ddl_statements.append(sql)
return
# For every other operation, we've got to ensure that
# any prior DDL statements were run.
# self._run_prior_DDL_statements()
self.connection.run_prior_DDL_statements()
if not self.connection.autocommit:
if classification == parse_utils.STMT_UPDATING:
sql = parse_utils.ensure_where_clause(sql)
if classification != parse_utils.STMT_INSERT:
sql, args = sql_pyformat_args_to_spanner(sql, args or None)
statement = Statement(
sql,
args,
get_param_types(args or None)
if classification != parse_utils.STMT_INSERT
else {},
ResultsChecksum(),
classification == parse_utils.STMT_INSERT,
)
(self._result_set, self._checksum,) = self.connection.run_statement(
statement
)
self._itr = PeekIterator(self._result_set)
return
if classification == parse_utils.STMT_NON_UPDATING:
self._handle_DQL(sql, args or None)
elif classification == parse_utils.STMT_INSERT:
_helpers.handle_insert(self.connection, sql, args or None)
else:
self.connection.database.run_in_transaction(
self._do_execute_update, sql, args or None
)
except (AlreadyExists, FailedPrecondition) as e:
 raise IntegrityError(e.details if hasattr(e, "details") else e)

E google.cloud.spanner_dbapi.exceptions.IntegrityError: 400 Duplicate name in schema: Singers.

../../google/cloud/spanner_dbapi/cursor.py:223: IntegrityError

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚨This issue needs some love.api: spannerIssues related to the googleapis/python-spanner API.flakybot: flakyTells the Flaky Bot not to close or comment on this issue.flakybot: issueAn issue filed by the Flaky Bot. Should not be added manually.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.samplesIssues that are directly related to samples.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions