-
-
Notifications
You must be signed in to change notification settings - Fork 44
Description
I was getting Boto errors in the logs of my Lambda's about expired transaction IDs when aurora_data_api tries to rollback a transaction.
AWS docs say that: "If the transaction ID has expired, the transaction was rolled back automatically. In this case, an aws rds-data rollback-transaction command that specifies the expired transaction ID returns an error."
So I tried catching that exception and ignoring it in aurora_data_api ... because presumably the transaction has already been rolled back automatically. I did this by adding a try/except around the rollback_transaction() call here:
| self._client.rollback_transaction(resourceArn=self._aurora_cluster_arn, |
try:
self._client.rollback_transaction(
resourceArn=self._aurora_cluster_arn,
secretArn=self._secret_arn,
transactionId=self._transaction_id,
)
except (BotoCoreError, ClientError) as exception:
logger.warning(
"Transaction ID has expired - ignoring rollback request. ",
extra={
"transaction_id": self._transaction_id,
"exception": str(exception),
},
)
And then in execute(), I had to add another elif after this one:
aurora-data-api/aurora_data_api/__init__.py
Line 227 in 509cefe
| elif "Database returned more than the allowed response size limit" in str(e): |
elif re.search(r"Transaction \S+ is not found", str(e)) or (
"Invalid transaction ID" in str(e)
):
self._transaction_id = None
self.execute(operation, parameters=parameters)
This seems to work, and I no longer get those errors, but I'm not at all sure it's a good (or even correct) solution. Or what the actual root of the problem is. I still get those warning logs I've added (Transaction ID has expired...) several times a day.