Background task -->anvil.tables.TableError: Internal database error: ERROR: canceling statement due to user request

Thank you! @meredydd, I’ll definitely explore these optimizations further.
Just to clarify, you’re indicating that the accelerated tables are returning more data compared to regular tables, which may be the source of the frequent timeout errors I’m experiencing? This explains why I did not experience any issues with the same code in the past.

Disregard this :point_down:

Also, regarding this error, I am updating a row;

would that considered fetching as well?

It turn out that there is another part of the code going very slow (still investigating :man_detective:) and causing multiple similar background task calls interfering with each other when they trying to update the same row :person_facepalming:.

The following code prevented the canceling statement error

def check_and_abort_task(n_task):
    current_tasks = anvil.server.list_background_tasks()
    for task in current_tasks:
        if task.get_task_name() == n_task.get_task_name() and task.is_running():
            task.kill()
            print(1645,f"Task {task_name} is already running. Aborting new task.")

I am not sure if there is a better way to stop the task before launching it :thinking: