Staging instance, all changes can be removed at any time

Skip to content

Return 0 slot if no more slots available in the queues

This scenario happens with the loader oneshot for example. This loader deals with more than 1 type of origins to ingest in the same queue. So the computation of that function returned negative value [1]. Which is ultimately not possible to execute in sql [1].

This commits fixes that behavior. This also explicits that the function must return positive values in its docstring.

  • [1]
...
psycopg2.errors.InvalidRowCountInLimitClause: LIMIT must not be negative
  • [2]
Traceback (most recent call last):
  File "/usr/bin/swh", line 11, in <module>
    load_entry_point('swh.core==0.15.0', 'console_scripts', 'swh')()
  File "/usr/lib/python3/dist-packages/swh/core/cli/__init__.py", line 185, in main
    return swh(auto_envvar_prefix="SWH")
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/swh/scheduler/cli/origin.py", line 205, in send_to_celery
    lister_uuid=lister_uuid,
  File "/usr/lib/python3/dist-packages/swh/core/db/common.py", line 62, in _meth
    return meth(self, *args, db=db, cur=cur, **kwargs)
  File "/usr/lib/python3/dist-packages/swh/scheduler/backend.py", line 525, in grab_next_visits                                                                                                                                                    cur.execute(query, tuple(query_args))
  File "/usr/lib/python3/dist-packages/psycopg2/extras.py", line 243, in execute
    return super(RealDictCursor, self).execute(query, vars)
psycopg2.errors.InvalidRowCountInLimitClause: LIMIT must not be negative

Test Plan

tox

patched in production and it no longer crashes with [2]


Migrated from D6487 (view on Phabricator)

Merge request reports

Loading