Rasa X interactive learning locked database

Getting a bug when running rasa x interactive learning, it gets stuck in this loop.

[SQL: UPDATE conversation SET number_user_messages=?, latest_event_time=? WHERE conversation.sender_id = ?]
[parameters: (1, 1561765551.79437, 'e4e12fe78a364e368f807aea42bc2a55')]
(Background on this error at: http://sqlalche.me/e/e3q8)
Caught an exception while consuming events. Will retry in 5s
Traceback (most recent call last):
  File "<DIR>/lib/python3.7/site-packages/rasax/community/services/event_service.py", line 924, in continuously_consume
    logs_service=_logs_service,
  File "<DIR>/lib/python3.7/site-packages/rasax/community/services/event_service.py", line 879, in __init__
    self.event_number = self._init_event_number()
  File "<DIR>/lib/python3.7/site-packages/rasax/community/services/event_service.py", line 883, in _init_event_number
    return self.event_store.get_latest_event_timestamp_and_event_number()[
  File "<DIR>/lib/python3.7/site-packages/rasax/community/services/event_service.py", line 213, in get_latest_event_timestamp_and_event_number
    existing = self.session.query(ConversationStatistic).first()
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3215, in first
    ret = list(self[0:1])
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3007, in __getitem__
    return list(res)
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3317, in __iter__
    return self._execute_and_instances(context)
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3339, in _execute_and_instances
    querycontext, self._connection_from_session, close_with_result=True
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3354, in _get_bind_args
    mapper=self._bind_mapper(), clause=querycontext.statement, **kw
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3332, in _connection_from_session
    conn = self.session.connection(**kw)
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1123, in connection
    execution_options=execution_options,
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1129, in _connection_for_bind
    engine, execution_options
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 407, in _connection_for_bind
    self._assert_active()
  File "<DIR>/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 294, in _assert_active
    % self._rollback_exception
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.OperationalError) database is locked
[SQL: UPDATE conversation SET number_user_messages=?, latest_event_time=? WHERE conversation.sender_id = ?]
[parameters: (1, 1561765551.79437, 'e4e12fe78a364e368f807aea42bc2a55')]
(Background on this error at: http://sqlalche.me/e/e3q8)

You are running the interactive learning with rasa interactive, is that right?

I have the same issue running interactive learning from rasa x. If I run it from command line interface with rasa interactive, everything is working fine. Any suggestions?

here is the message I get running interactive learning from rasa x:

Caught an exception while consuming events. Will retry in 5s
Traceback (most recent call last):
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/rasax/community/services/event_service.py", line 924, in continuously_consume
    consumer.consume()
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/rasax/community/services/event_service.py", line 893, in consume
    run()
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/rasax/community/services/event_service.py", line 885, in run
    event, sender_id=sender_id, event_number=event_number
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/rasax/community/services/event_service.py", line 70, in save_event
    self._update_conversation_metadata(event)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/rasax/community/services/event_service.py", line 137, in _update_conversation_metadata
    unique_intents = (i.intent for i in conversation.unique_intents)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 282, in __get__
    return self.impl.get(instance_state(instance), dict_)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 699, in get
    value = self.callable_(state, passive)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/strategies.py", line 723, in _load_for_state
    session, state, primary_key_identity, passive
  File "<string>", line 1, in <lambda>
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/strategies.py", line 865, in _emit_lazyload
    .with_post_criteria(set_default_params)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/ext/baked.py", line 531, in all
    return list(self)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/ext/baked.py", line 429, in __iter__
    self.session._autoflush()
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1588, in _autoflush
    util.raise_from_cause(e)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 399, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 154, in reraise
    raise value
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1577, in _autoflush
    self.flush()
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2459, in flush
    self._flush(objects)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2597, in _flush
    transaction.rollback(_capture_exception=True)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 154, in reraise
    raise value
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2557, in _flush
    flush_context.execute()
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
    rec.execute(self)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
    uow,
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 236, in save_obj
    update,
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 996, in _emit_update_statements
    statement, multiparams
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 988, in execute
    return meth(self, multiparams, params)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
    distilled_params,
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 399, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
    raise value.with_traceback(tb)
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/home/namex/environments/rasa/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 550, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(sqlite3.OperationalError) database is locked
[SQL: UPDATE conversation SET number_user_messages=?, latest_event_time=? WHERE conversation.sender_id = ?]
[parameters: (1, 1562757600.1061697, '3c0239a3c0774ccd9d16785efca01405')]
(Background on this error at: http://sqlalche.me/e/e3q8)

any help would be appreciated :slight_smile:

Interactive learning through the rasa-x web interface, NOT the command line …

I think the sqlite database is getting to many concurrent requests. Could you try

sqlite rasa.db
# and then in sqlite
PRAGMA journal_mode=WAL;

and then re-running Rasa whether the error is gone?

Thank you for the fast reply!

I tried what you have suggested, but the error still persist.

I can use rasa x interactive learning without any problems on ubuntu 16, the described error happens in my case on ubuntu 18, maybe it can help in some way…

I’ve got the same error with this. I can do interactive learning with a demo project created by rasa init --no-prompt . But that’s not work for a real project. Wish some rasa guy helps! Thanks!!! @juste_petr

I have the same problem, is there an update on this?