ArtVentureX / sd-webui-agent-scheduler

641 stars 68 forks source link

task ID repeat error #97

Closed Maverous closed 1 year ago

Maverous commented 1 year ago

I keep getting an id error in the SD Client every time a new task starts. It hasn't affected my outputs yet, but I'm not sure if its going to mess with the SD Client's ability to reman queued up. This is the code that shows up after every new task starts:

Traceback (most recent call last):
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1965, in _exec_single_context
    self.dialect.do_execute(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\default.py", line 921, in do_execute
    cursor.execute(statement, parameters)
sqlite3.IntegrityError: UNIQUE constraint failed: task.id

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
    output = await app.get_blocks().process_api(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
    result = await self.call_function(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\scripts\task_scheduler.py", line 229, in f
    task_runner.register_ui_task(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\agent_scheduler\task_runner.py", line 279, in register_ui_task
    task_manager.add_task(task)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\agent_scheduler\db\task.py", line 207, in add_task
    raise e
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\agent_scheduler\db\task.py", line 203, in add_task
    session.commit()
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 1920, in commit
    trans.commit(_to_root=True)
  File "<string>", line 2, in commit
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 1236, in commit
    self._prepare_impl()
  File "<string>", line 2, in _prepare_impl
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 1211, in _prepare_impl
    self.session.flush()
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 4163, in flush
    self._flush(objects)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 4298, in _flush
    with util.safe_reraise():
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 4259, in _flush
    flush_context.execute()
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 466, in execute
    rec.execute(self)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 642, in execute
    util.preloaded.orm_persistence.save_obj(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\persistence.py", line 93, in save_obj
    _emit_insert_statements(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\persistence.py", line 1226, in _emit_insert_statements
    result = connection.execute(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1412, in execute
    return meth(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\sql\elements.py", line 483, in _execute_on_connection
    return connection._execute_clauseelement(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1635, in _execute_clauseelement
    ret = self._execute_context(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1844, in _execute_context
    return self._exec_single_context(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1984, in _exec_single_context
    self._handle_dbapi_exception(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 2339, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1965, in _exec_single_context
    self.dialect.do_execute(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\default.py", line 921, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: task.id
[SQL: INSERT INTO task (id, api_task_id, api_task_callback, name, type, params, script_params, priority, status, result, bookmarked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING created_at, updated_at]
[parameters: ('task(trmj9oa0hn0haxl)', None, None, None, 'img2img', '{"args": {"id_task": "task(trmj9oa0hn0haxl)", "mode": 2, "prompt": "Cathar male Smuggler dramatically posed to with guns drawn aiming to the left, an ... (1320735 characters truncated) ... lip skip: 1"], "sampler_name": "DPM++ 2M SDE Karras"}, "checkpoint": "virileFantasy_v11.safetensors [5fff333e32]", "is_ui": true, "is_img2img": true}', <memory at 0x0000028BD5583E80>, 1690829174005, 'pending', None, 0)]

From what I can understand its having issues with UNIQUIE SQL INSERTS. Is this an instability of the Scheduler extension or a conflict with other extensions? And will it cause problems for the extension?

artventuredev commented 1 year ago

Are you getting this every time you queue a task? Can you post your extension list on the SD web UI?

Maverous commented 1 year ago

Its happens only when I que up a new task from what I can see on the client screen. This is what the whole thing from point A to Point B has given me (I hope this is what you were asking for):

exception adding task to database: (sqlite3.IntegrityError) UNIQUE constraint failed: task.id 
 [3:40:16<57:09, 29.31s/it]
[SQL: INSERT INTO task (id, api_task_id, api_task_callback, name, type, params, script_params, priority, status, result, bookmarked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING created_at, updated_at]
[parameters: ('task(qgyqkmcj9amxidr)', None, None, None, 'txt2img', '{"args": {"id_task": "task(qgyqkmcj9amxidr)", "prompt": "solo, nude Cathar male with yellow fur and black stripes leaning on a railing on the edge of ... (2028 characters truncated) ... texts": ["Clip skip: 1"], "sampler_name": "Euler a"}, "checkpoint": "virileFantasy_v11.safetensors [5fff333e32]", "is_ui": true, "is_img2img": false}', <memory at 0x0000028BD5582380>, 1690838571180, 'pending', None, 0)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
Traceback (most recent call last):
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1965, in _exec_single_context
    self.dialect.do_execute(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\default.py", line 921, in do_execute
    cursor.execute(statement, parameters)
sqlite3.IntegrityError: UNIQUE constraint failed: task.id

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
    output = await app.get_blocks().process_api(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
    result = await self.call_function(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\scripts\task_scheduler.py", line 229, in f
    task_runner.register_ui_task(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\agent_scheduler\task_runner.py", line 279, in register_ui_task
    task_manager.add_task(task)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\agent_scheduler\db\task.py", line 207, in add_task
    raise e
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\extensions\sd-webui-agent-scheduler\agent_scheduler\db\task.py", line 203, in add_task
    session.commit()
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 1920, in commit
    trans.commit(_to_root=True)
  File "<string>", line 2, in commit
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 1236, in commit
    self._prepare_impl()
  File "<string>", line 2, in _prepare_impl
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 1211, in _prepare_impl
    self.session.flush()
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 4163, in flush
    self._flush(objects)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 4298, in _flush
    with util.safe_reraise():
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 4259, in _flush
    flush_context.execute()
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 466, in execute
    rec.execute(self)
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 642, in execute
    util.preloaded.orm_persistence.save_obj(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\persistence.py", line 93, in save_obj
    _emit_insert_statements(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\orm\persistence.py", line 1226, in _emit_insert_statements
    result = connection.execute(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1412, in execute
    return meth(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\sql\elements.py", line 483, in _execute_on_connection
    return connection._execute_clauseelement(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1635, in _execute_clauseelement
    ret = self._execute_context(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1844, in _execute_context
    return self._exec_single_context(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1984, in _exec_single_context
    self._handle_dbapi_exception(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 2339, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1965, in _exec_single_context
    self.dialect.do_execute(
  File "F:\AI Stuff\Stable Diffusion\WebUI\stable-diffusion-webui\venv\lib\site-packages\sqlalchemy\engine\default.py", line 921, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: task.id
[SQL: INSERT INTO task (id, api_task_id, api_task_callback, name, type, params, script_params, priority, status, result, bookmarked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING created_at, updated_at]
[parameters: ('task(qgyqkmcj9amxidr)', None, None, None, 'txt2img', '{"args": {"id_task": "task(qgyqkmcj9amxidr)", "prompt": "solo, nude Cathar male with yellow fur and black stripes leaning on a railing on the edge of ... (2028 characters truncated) ... texts": ["Clip skip: 1"], "sampler_name": "Euler a"}, "checkpoint": "virileFantasy_v11.safetensors [5fff333e32]", "is_ui": true, "is_img2img": false}', <memory at 0x0000028BD5582380>, 1690838571180, 'pending', None, 0)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
wogam commented 1 year ago

I get the exact same error, once the error occurs it will keep on repeating until I restart the web ui. Only extension is this and controlnet (controlnet is not active)

artventuredev commented 1 year ago

@wogam @Maverous The issue is fixed on the latest commit, please give it a try.