From 3569980378b5111fbe30454dae944168854f7e82 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Tue, 30 Aug 2016 23:18:40 +0200 Subject: [PATCH] Fix error reporting of catalogs. The internal catalog representation are deeply recursive in order to make it easy to traverse the catalog both downwards (catalog to schema to tables) and upward (table to its schema to its catalog). In consequence we need to set *print-circles* to non-nil when we're going to log the catalogs, so turn it to non-nil before generating the log messages. While at it, add logging of such catalogs in the :data log verbosity mode. The catalog output is very verbose, but it's easy to copy/paste it from a bug report into being a live object we can inspect in the REPL, thanks to Common Lisp notion of a reader and readable printer! --- src/sources/common/db-methods.lisp | 5 ++++- src/sources/common/md-methods.lisp | 2 ++ src/utils/monitor.lisp | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/sources/common/db-methods.lisp b/src/sources/common/db-methods.lisp index 7ed9718..188094a 100644 --- a/src/sources/common/db-methods.lisp +++ b/src/sources/common/db-methods.lisp @@ -98,7 +98,10 @@ (with-stats-collection ("Create MatViews Tables" :section :pre :use-result-as-read t :use-result-as-rows t) - (create-views catalog :include-drop include-drop))))) + (create-views catalog :include-drop include-drop)))) + + ;; log the catalog we just fetched and (maybe) merged + (log-message :data "CATALOG: ~s" catalog)) (defmethod cleanup ((copy db-copy) (catalog catalog) &key materialize-views) "In case anything wrong happens at `prepare-pgsql-database' step, this diff --git a/src/sources/common/md-methods.lisp b/src/sources/common/md-methods.lisp index 3e6185f..f1edb03 100644 --- a/src/sources/common/md-methods.lisp +++ b/src/sources/common/md-methods.lisp @@ -121,6 +121,8 @@ (list (column-name col))) (table-field-list (first (table-list pgsql-catalog)))))) + (log-message :data "CATALOG: ~s" pgsql-catalog) + ;; this sets (table-index-list (target copy)) (maybe-drop-indexes pgsql-catalog :drop-indexes drop-indexes) diff --git a/src/utils/monitor.lisp b/src/utils/monitor.lisp index 34924e3..b4a7b74 100644 --- a/src/utils/monitor.lisp +++ b/src/utils/monitor.lisp @@ -194,12 +194,12 @@ (log-message ;; cl-log:log-message is a macro, we can't use apply ;; here, so we need to break a level of abstraction - (let ((mesg (if (log-message-arguments event) - (format nil "~{~}" - (log-message-description event) - (log-message-arguments event)) - (log-message-description event))) - (*print-circle* t)) + (let* ((*print-circle* t) + (mesg (if (log-message-arguments event) + (format nil "~{~}" + (log-message-description event) + (log-message-arguments event)) + (log-message-description event)))) (cl-log:log-message (log-message-category event) "~a" mesg))) (new-label