Internal database error

What I’m trying to do:
I have a background task which writes to a Data Table. Sporadically (~5% of runs) it fails with the following error (I’ve redacted some sensitive details with XXX-ZZZ).

anvil.tables.TableError: Internal database error: Batch entry 0 UPDATE app_storage_data SET data = XXX::jsonb WHERE table_id = YYY AND id = ZZZ was aborted: ERROR: canceling statement due to user request  Call getNextException to see other errors in the batch.

I can’t think of anything I’m doing wrong and this code used to run error-free up until about sometime last week.

Side note: I previously had Accelerated Tables turned on but was getting transaction conflict errors (despite no in_transaction decorators nor transaction context managers in the code). These errors went away when disabled Accelerated Tables, but have now been replaced by the errors mentioned above, albeit at a lower frequency.

Anvil staff: you can view examples of these errors here:

Thanks very much!
Simon