Skip to content

Conversation

@louisradtke
Copy link

Fixes the worker's behavior to register trashed bags that are still available in a store.

Uses the solution @hfchendrikx has stated in this comment.

closes #1

@abrandemuehl
Copy link
Contributor

Seems like it's the right way to do it from Huub's suggestion. I assume you've tested it on your instance?

@louisradtke
Copy link
Author

louisradtke commented Apr 21, 2022

There is something I couldn't figure out yet: Before cf524f0, when I tried to register a new bag, the API server answers with a status code 500. This is caused by a violated SQL constraint, where in_trash is null. I am curious about why this worked before there were deleted bags in that specific store. Shouldn't it always fail?

Anyways, now it is tested and works on my stack.

This is what happened on the server's side
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
psycopg2.IntegrityError: null value in column "in_trash" violates not-null constraint
DETAIL:  Failing row contains (29, 5, {"s3": {"path": "2022-04-04-18-15-54.bag"}}, 2022-04-04-18-15-54.bag, f, null, f, 2022-04-21 08:43:50.854456, f, 0, null, null, null, null, null, null, null, ).


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

Traceback (most recent call last):
  File "/var/app/rbb_server/src/rbb_server/controllers/bag_controller.py", line 491, in put_bag_meta
    session.commit()
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 157, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 921, in commit
    self.transaction.commit()
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 461, in commit
    self._prepare_impl()
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 441, in _prepare_impl
    self.session.flush()
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2192, in flush
    self._flush(objects)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2312, in _flush
    transaction.rollback(_capture_exception=True)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2276, in _flush
    flush_context.execute()
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 389, in execute
    rec.execute(self)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 548, in execute
    uow
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 177, in save_obj
    mapper, table, update)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 737, in _emit_update_statements
    execute(statement, multiparams)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)

@abrandemuehl
Copy link
Contributor

abrandemuehl commented Apr 21, 2022

Seems like adding the comparison on in_trash caused a query to reference it? It probably isn't being queried anywhere else, but you can check in a quick search for it. Probably you'll need to update a DB query that makes the value of null equivalent to false.

One way to fix it is probably to update the code to always set it to false for new bags so that it isn't null anywhere

@louisradtke
Copy link
Author

But when doing this (avoiding None for in_trash), shouldn't we do this for every other variable, too? The thing is that in the rbb_core, I can't find any any occurrence which has to do with this, where in_trash is set explicitly to anything else than None.

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

Successfully merging this pull request may close these issues.

[Bug] Exception when reindexing trashed file.

2 participants