Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto update index may cause error #45

Open
easypickings opened this issue Nov 1, 2020 · 1 comment
Open

auto update index may cause error #45

easypickings opened this issue Nov 1, 2020 · 1 comment

Comments

@easypickings
Copy link

easypickings commented Nov 1, 2020

When I set MSEARCH_ENABLE = True and try to add a new record to the table, it raises error like

Traceback (most recent call last):
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/Users/sucan/compNet/app/routes.py", line 287, in record_add
    db.session.commit()
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/scoping.py", line 162, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1036, in commit
    self.transaction.commit()
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 510, in commit
    self.session.dispatch.after_commit(self.session)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/event/attr.py", line 322, in __call__
    fn(*args, **kw)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 224, in after_commit
    models_committed.send(session.app, changes=list(d.values()))
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/blinker/base.py", line 267, in send
    for receiver in self.receivers_for(sender)]
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/blinker/base.py", line 267, in <listcomp>
    for receiver in self.receivers_for(sender)]
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask_msearch/backends.py", line 121, in index_signal
    return self._signal(self, sender, changes)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask_msearch/signal.py", line 42, in default_signal
    backend.create_one_index(instance)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask_msearch/whoosh_backend.py", line 190, in create_one_index
    attrs[field] = str(relation_column(instance, field.split('.')))
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/flask_msearch/backends.py", line 30, in relation_column
    _field = getattr(instance, fields[0])
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 282, in __get__
    return self.impl.get(instance_state(instance), dict_)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 710, in get
    value = self.callable_(state, passive)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/strategies.py", line 747, in _load_for_state
    session, state, primary_key_identity, passive
  File "<string>", line 1, in <lambda>
    
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/strategies.py", line 837, in _emit_lazyload
    session.query(self.mapper), primary_key_identity
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/ext/baked.py", line 612, in _load_on_pk_identity
    result = list(bq.for_session(self.session).params(**params))
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/ext/baked.py", line 444, in __iter__
    return q._execute_and_instances(context)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3411, in _execute_and_instances
    querycontext, self._connection_from_session, close_with_result=True
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3426, in _get_bind_args
    mapper=self._bind_mapper(), clause=querycontext.statement, **kw
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3404, in _connection_from_session
    conn = self.session.connection(**kw)
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1133, in connection
    execution_options=execution_options,
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1139, in _connection_for_bind
    engine, execution_options
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 408, in _connection_for_bind
    self._assert_active()
  File "/Users/sucan/compNet/new_venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 276, in _assert_active
    "This session is in 'committed' state; no further "
sqlalchemy.exc.InvalidRequestError: This session is in 'committed' state; no further SQL can be emitted within this transaction.

When set MSEARCH_ENABLE = False, the error disappears. So I guess something with update index may cause error?

@easypickings
Copy link
Author

seems mentioned in #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant