The ovsdb-server compaction timing logic is written assuming milliscond resolution timestamps but ovsdb-server wrote second resolution timestamps.
This commit changes ovsdb-server to write millisecond resolution timestamps and ovsdb-tool to report millisecond timestamps. This raises two compatibility issues: 1. When a new ovsdb-server or ovsdb-tool reads an old database, it will multiply by 1000 any timestamp it reads which is less than 1<<31. Since this date corresponds to Jan 16 1970 this is unlikely to cause a problem. 2. When an old ovsdb-tool reads a new database, it will interpret the millisecond timestamps as seconds and report dates in the far future; the time of this commit is reported as the year 45645 (each second since the epoch is interpreted as 16 minutes). (When an old ovsdb-server reads a new database there is no problem, it is already interpreting the timestamps in milliseconds). --- ovsdb/file.c | 6 +++++- ovsdb/ovsdb-tool.c | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ovsdb/file.c b/ovsdb/file.c index b02d5a3..5b79f8c 100644 --- a/ovsdb/file.c +++ b/ovsdb/file.c @@ -408,6 +408,10 @@ ovsdb_file_txn_from_json(struct ovsdb *db, const struct json *json, if (!strcmp(table_name, "_date") && node_json->type == JSON_INTEGER) { *date = json_integer(node_json); + if (*date < INT_MAX) { + /* Older versions of ovsdb wrote timestamps in seconds. */ + *date *= 1000; + } continue; } else if (!strcmp(table_name, "_comment") || converting) { continue; @@ -787,7 +791,7 @@ ovsdb_file_txn_commit(struct json *json, const char *comment, if (comment) { json_object_put_string(json, "_comment", comment); } - json_object_put(json, "_date", json_integer_create(time_wall())); + json_object_put(json, "_date", json_integer_create(time_wall_msec())); error = ovsdb_log_write(log, json); json_destroy(json); diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c index 7cd0485..9c7eeb2 100644 --- a/ovsdb/ovsdb-tool.c +++ b/ovsdb/ovsdb-tool.c @@ -518,8 +518,8 @@ do_show_log(int argc, char *argv[]) date = shash_find_data(json_object(json), "_date"); if (date && date->type == JSON_INTEGER) { - time_t t = json_integer(date); - char *s = xastrftime(" %Y-%m-%d %H:%M:%S", t, true); + long long int t = json_integer(date); + char *s = xastrftime_msec(" %Y-%m-%d %H:%M:%S.%.", t, true); fputs(s, stdout); free(s); } -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev