Skip to content

Commit

Permalink
ovsdb: write commit timestamps to millisecond resolution.
Browse files Browse the repository at this point in the history
This is expected to make system debugging easier.

This raises two compatibility issues:
1. When a new 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 45672 (each second since the
  epoch is interpreted as 16 minutes).

Signed-off-by: Paul Ingram <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
Paul Ingram authored and blp committed Sep 16, 2013
1 parent 2958f35 commit 1ff1065
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Post-v2.0.0
---------------------
- Log files now report times with millisecond resolution. (Previous
versions only reported whole seconds.)
- Log file timestamps and ovsdb commit timestamps are now reported
with millisecond resolution. (Previous versions only reported
whole seconds.)


v2.0.0 - xx xxx xxxx
Expand Down
2 changes: 1 addition & 1 deletion ovsdb/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,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);
Expand Down
12 changes: 9 additions & 3 deletions ovsdb/ovsdb-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,15 @@ 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_msec(" %Y-%m-%d %H:%M:%S",
t * 1000LL, true);
long long int t = json_integer(date);
char *s;

if (t < INT32_MAX) {
/* Older versions of ovsdb wrote timestamps in seconds. */
t *= 1000;
}

s = xastrftime_msec(" %Y-%m-%d %H:%M:%S.###", t, true);
fputs(s, stdout);
free(s);
}
Expand Down

0 comments on commit 1ff1065

Please sign in to comment.