wrong values for timestamp are stored in action table

Bug #1746123 reported by Duc Truong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
senlin
Fix Released
Medium
Duc Truong

Bug Description

start_time and end_time for actions are stored as FLOAT(24,8) in the DB (https://github.com/openstack/senlin/blob/master/senlin/db/sqlalchemy/models.py#L232). This will store the wrong value in the DB because float values are are treated as approximate values by mysql: https://dev.mysql.com/doc/refman/5.7/en/problems-with-float.html

E.g.:
mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> use test;
Database changed

mysql> create table test1 (id INT, time FLOAT(24,8));
Query OK, 0 rows affected (0.02 sec)

mysql> describe test1;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| time | float(24,8) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.02 sec)

mysql> insert into test1 (id, time) value (1, 1517248704);
Query OK, 1 row affected (0.00 sec)

mysql> select * from test1;
+------+---------------------+
| id | time |
+------+---------------------+
| 1 | 1517248768.00000000 |
+------+---------------------+
1 row in set (0.00 sec)

The value stored in the DB does not match the passed in value for float types. This causes action timeout to be inaccurate as it relies on the start_time stored in the DB.

Qiming Teng (tengqim)
Changed in senlin:
status: New → Triaged
importance: Undecided → Medium
Duc Truong (dtruong)
Changed in senlin:
assignee: nobody → Duc Truong (dtruong)
Duc Truong (dtruong)
Changed in senlin:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to senlin (master)

Fix proposed to branch: master
Review: https://review.openstack.org/554385

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to senlin (master)

Reviewed: https://review.openstack.org/554385
Committed: https://git.openstack.org/cgit/openstack/senlin/commit/?id=3f1b2b68b0c1bfa12ed3c3eac8e59fc99e53b8b0
Submitter: Zuul
Branch: master

commit 3f1b2b68b0c1bfa12ed3c3eac8e59fc99e53b8b0
Author: Duc Truong <email address hidden>
Date: Wed Mar 14 21:19:41 2018 +0000

    Use decimal type for start_time and end_time

    * Change start_time and end_time type in action model
    * Add db migration script for start_time and end_time type change

    Using float type for start_time and end_time caused inaccurate
    timestamps to be stored [1]. This change uses decimal type for
    start_time and end_time.

    [1] https://dev.mysql.com/doc/refman/5.7/en/problems-with-float.html

    Change-Id: Ia6c1f0a0379695edfbb9e6f32a1e799927f05fc3
    Closes-Bug: #1746123

Changed in senlin:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/senlin 6.0.0.0b1

This issue was fixed in the openstack/senlin 6.0.0.0b1 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.