dagobah icon indicating copy to clipboard operation
dagobah copied to clipboard

(ProgrammingError) library routine called out of sequence

Open zhenlongbai opened this issue 9 years ago • 5 comments

I don't know why it happen . The error doesn't happen everytime . I find the error with '\n' in the query .

ERROR root library routine called out of sequence u'SELECT dagobah_job.id AS dagobah_job_id, dagobah_job.parent_id AS dagobah_job_parent_id, dagobah_job.name AS dagobah_job_name, dagobah_job.status AS dagobah_job_status, dagobah_job.cron_schedule AS dagobah_job_cron_schedule, dagobah_job.next_run AS dagobah_job_next_run, dagobah_job.notes AS dagobah_job_notes \nFROM dagobah_job \nWHERE dagobah_job.id = ?\n LIMIT ? OFFSET ?' (5, 1, 0) Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/dagobah/daemon/util.py", line 47, in wrapper result = fn(_args, *_kwargs) File "/usr/local/lib/python2.7/site-packages/dagobah/daemon/api.py", line 263, in schedule_job job.schedule(args['cron_schedule']) File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 376, in schedule self.commit() File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 301, in commit self.backend.commit_job(self._serialize()) File "/usr/local/lib/python2.7/site-packages/dagobah/backend/sqlite.py", line 137, in commit_job filter_by(id=job_json['job_id']).
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2370, in first ret = list(self[0:1]) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2231, in getitem return list(res) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2441, in iter return self._execute_and_instances(context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2456, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 841, in execute return meth(self, multiparams, params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 322, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 938, in _execute_clauseelement compiled_sql, distilled_params File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1070, in _execute_context context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1271, in _handle_dbapi_exception exc_info File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1063, in _execute_context context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 442, in do_execute cursor.execute(statement, parameters) ProgrammingError: (ProgrammingError) library routine called out of sequence u'SELECT dagobah_job.id AS dagobah_job_id, dagobah_job.parent_id AS dagobah_job_parent_id, dagobah_job.name AS dagobah_job_name, dagobah_job.status AS dagobah_job_status, dagobah_job.cron_schedule AS dagobah_job_cron_schedule, dagobah_job.next_run AS dagobah_job_next_run, dagobah_job.notes AS dagobah_job_notes \nFROM dagobah_job \nWHERE dagobah_job.id = ?\n LIMIT ? OFFSET ?' (5, 1, 0) Exception in thread Thread-3113: Traceback (most recent call last): File "/usr/local/lib/python2.7/threading.py", line 551, in __bootstrap_inner self.run() File "/usr/local/lib/python2.7/threading.py", line 755, in run self.function(_self.args, *_self.kwargs) File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 824, in check_complete complete_time=datetime.utcnow()) File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 1027, in _task_complete self.parent_job._complete_task(self.name, **kwargs) File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 529, in _complete_task self._commit_run_log() File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 624, in _commit_run_log self.backend.commit_log(self.run_log) File "/usr/local/lib/python2.7/site-packages/dagobah/backend/sqlite.py", line 169, in commit_log filter_by(id=log_json['log_id']).
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2370, in first ret = list(self[0:1]) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2231, in getitem return list(res) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2441, in iter return self._execute_and_instances(context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2456, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 841, in execute return meth(self, multiparams, params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 322, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 938, in _execute_clauseelement compiled_sql, distilled_params File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1070, in _execute_context context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1271, in _handle_dbapi_exception exc_info File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1063, in _execute_context context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 442, in do_execute cursor.execute(statement, parameters) ProgrammingError: (ProgrammingError) library routine called out of sequence u'SELECT dagobah_log.id AS dagobah_log_id, dagobah_log.job_id AS dagobah_log_job_id, dagobah_log.start_time AS dagobah_log_start_time, dagobah_log.last_retry_time AS dagobah_log_last_retry_time, dagobah_log.save_date AS dagobah_log_save_date \nFROM dagobah_log \nWHERE dagobah_log.id = ?\n LIMIT ? OFFSET ?' (560, 1, 0)

ERROR [dagobah.daemon.daemon] Exception on /api/schedule_job [POST] Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request return self.view_functionsrule.endpoint File "/usr/local/lib/python2.7/site-packages/flask_login.py", line 663, in decorated_view return func(_args, *_kwargs) File "/usr/local/lib/python2.7/site-packages/dagobah/daemon/util.py", line 54, in wrapper raise e ProgrammingError: (ProgrammingError) library routine called out of sequence u'SELECT dagobah_job.id AS dagobah_job_id, dagobah_job.parent_id AS dagobah_job_parent_id, dagobah_job.name AS dagobah_job_name, dagobah_job.status AS dagobah_job_status, dagobah_job.cron_schedule AS dagobah_job_cron_schedule, dagobah_job.next_run AS dagobah_job_next_run, dagobah_job.notes AS dagobah_job_notes \nFROM dagobah_job \nWHERE dagobah_job.id = ?\n LIMIT ? OFFSET ?' (5, 1, 0) Exception in thread Thread-3114: Traceback (most recent call last): File "/usr/local/lib/python2.7/threading.py", line 551, in **bootstrap_inner self.run() File "/usr/local/lib/python2.7/threading.py", line 755, in run self.function(_self.args, *_self.kwargs) File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 824, in check_complete complete_time=datetime.utcnow()) File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 1027, in _task_complete self.parent_job._complete_task(self.name, kwargs) File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 529, in _complete_task self._commit_run_log() File "/usr/local/lib/python2.7/site-packages/dagobah/core/core.py", line 624, in _commit_run_log self.backend.commit_log(self.run_log) File "/usr/local/lib/python2.7/site-packages/dagobah/backend/sqlite.py", line 169, in commit_log filter_by(id=log_json['log_id']).
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2370, in first ret = list(self[0:1]) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2231, in __getitem
return list(res) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2441, in iter return self._execute_and_instances(context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2456, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 841, in execute return meth(self, multiparams, params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 322, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 938, in _execute_clauseelement compiled_sql, distilled_params File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1070, in _execute_context context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1271, in _handle_dbapi_exception exc_info File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1063, in _execute_context context) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 442, in do_execute cursor.execute(statement, parameters) ProgrammingError: (ProgrammingError) library routine called out of sequence u'SELECT dagobah_log.id AS dagobah_log_id, dagobah_log.job_id AS dagobah_log_job_id, dagobah_log.start_time AS dagobah_log_start_time, dagobah_log.last_retry_time AS dagobah_log_last_retry_time, dagobah_log.save_date AS dagobah_log_save_date \nFROM dagobah_log \nWHERE dagobah_log.id = ?\n LIMIT ? OFFSET ?' (561, 1, 0)

zhenlongbai avatar Apr 16 '15 11:04 zhenlongbai

You are finding a bunch of crazy stuff. :smile: I wonder if these are all just symptoms of the Unicode issue?

thieman avatar Apr 16 '15 12:04 thieman

The error doesn't happen everytime . so I can't debug .

I am reading you code ,and I want to know ,if I use the MongoDB or Mysql ,can I skip the errors.

zhenlongbai avatar Apr 17 '15 02:04 zhenlongbai

It's possible if everything is already UTF-8 that Mongo might work, though I know we have some other issues with encoding where we need to specifically coerce stuff to UTF-8 at points for Mongo's sake. Unfortunately, it's not a problem I have a great grasp on right now. More investigation is required.

thieman avatar Apr 17 '15 04:04 thieman

OK,I 'm checking the mongo . I will tell you the result . Thanks for you share.

zhenlongbai avatar Apr 17 '15 04:04 zhenlongbai

I change the the code in ./daemon/views.py and as follow, and I find it works normal with Chinese. When the value in list ,dict , it display like Job {name : u'\u4e2d\u662f'} , and Job['name']='中国'

@app.route('/job/<job_id>/<task_name>', methods=['GET']) @login_required def task_detail(job_id=None, task_name=None): """ Show a detailed description of a specific task. """ jobs = get_jobs() job = [job for job in jobs if str(job['job_id']) == job_id][0] task_current=None for task in job['tasks']:
print task['name'] if task['name'] == task_name: task_current=task return render_template('task_detail.html', job=job, task_name=task_name, task=task_current )

./daemon/util.py def validate_dict(in_dict, **kwargs): """ Returns Boolean of whether given dict conforms to type specifications given in kwargs. """ if not isinstance(in_dict, dict): raise ValueError('requires a dictionary') for key, value in kwargs.iteritems():

    if key == 'required':
        for required_key in value:
            if required_key not in in_dict:
                return False

    elif key not in in_dict:
        continue

    elif value == bool:

        in_dict[key] = (True
                        if str(in_dict[key]).lower() == 'true'
                        else False)

    else:

        if (isinstance(in_dict[key], list) and
            len(in_dict[key]) == 1 and
            value != list):
            in_dict[key] = in_dict[key][0]

        try:
            if key in in_dict:       
                    if value !=str:    # remove str checking
                            in_dict[key] = value(in_dict[key])

        except ValueError:
            return False

return True

zhenlongbai avatar Apr 22 '15 02:04 zhenlongbai