datetime used for string column query crashed postgresql driver
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
Undecided
|
Wenhao Xu |
Bug Description
branch: master
testing commit: cd4093e0f2a7d07
The sql database is postgresql 9.1. The driver is psycopg2.
You can easily reproduce it by enabling instance_
This bug should influence released version too if it is there for a long time.
The trace is here:
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager Traceback (most recent call last):
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "/home/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager task(self, context)
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "/home/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager if not compute_
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "/home/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager begin, end, host)
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "/home/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager period_ending, host, state, session)
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "/home/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager return f(*args, **kwargs)
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "/home/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager return query.first()
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "build/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager ret = list(self[0:1])
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "build/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager return list(res)
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "build/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager return self._execute_
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "build/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager result = conn.execute(
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "build/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager params)
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "build/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager compiled_sql, distilled_params
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "build/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager context)
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager File "build/
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager None, sys.exc_info()[2]
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager ProgrammingError: (ProgrammingError) operator does not exist: character varying = timestamp without time zone
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager LINE 3: ...stance_
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager ^
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
2013-01-22 00:39:54,100.100 30323 TRACE nova.manager 'SELECT task_log.created_at AS task_log_
description: | updated |
Changed in nova: | |
assignee: | nobody → Wenhao Xu (wenhao-x) |
status: | New → In Progress |
Changed in nova: | |
milestone: | none → grizzly-3 |
status: | Fix Committed → Fix Released |
Changed in nova: | |
milestone: | grizzly-3 → 2013.1 |
The period_beginning and period_ending is string type defined in the model. But the query passing in is datetime. So postgresql is confused about this type mismatch, I guess.
class TaskLog(BASE, NovaBase): beginning = Column(String(255), default= timeutils. utcnow) timeutils. utcnow)
"""Audit log for background periodic tasks."""
__tablename__ = 'task_log'
id = Column(Integer, primary_key=True, nullable=False, autoincrement=True)
task_name = Column(String(255), nullable=False)
state = Column(String(255), nullable=False)
host = Column(String(255))
period_
period_ending = Column(String(255), default=
message = Column(String(255), nullable=False)
task_items = Column(Integer(), default=0)
errors = Column(Integer(), default=0)
By converting the datetime to str before the SQLAlchemy query should fix the problem.