ovsdb: write commit timestamps to millisecond resolution.
authorPaul Ingram <pingram@nicira.com>
Sat, 14 Sep 2013 01:52:54 +0000 (18:52 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 17 Sep 2013 20:56:46 +0000 (13:56 -0700)
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 <pingram@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
NEWS
ovsdb/file.c
ovsdb/ovsdb-tool.c

diff --git a/NEWS b/NEWS
index 9df7f85..e4f1e8d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -24,8 +24,9 @@ v2.0.0 - xx xxx xxxx
       * New "ofp-parse" for printing OpenFlow messages read from a file.
     - Added configurable flow caching support to IPFIX exporter.
     - Dropped support for Linux pre-2.6.32.
-    - 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.)
 
 
 v1.11.0 - 28 Aug 2013
index 4ccf33e..7c8ac6f 100644 (file)
@@ -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);
index 8670127..077e7f5 100644 (file)
@@ -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);
             }