   [version :- s/Keyword
    query-map
    context :- query-context-schema]
-  (if use-preferred-streaming-method?
-    (preferred-produce-streaming-body version query-map context)
-    (deprecated-produce-streaming-body version query-map context)))
+  ;; For now, generate the ids here; perhaps later, higher up
+  (assert (not (:query-id context)))
+  (let [context (assoc context :query-id (str (java.util.UUID/randomUUID)))]
+    (if use-preferred-streaming-method?
+      (preferred-produce-streaming-body version query-map context)
+      (deprecated-produce-streaming-body version query-map context))))
 
 (pls/defn-validated object-exists? :- s/Bool
   "Returns true if an object exists."

  if an exception happens before then.  An exception thrown by the
  future after that point will produce an exception from the next call
  to the InputStream read or close methods."
  [db query entity version query-options log-id munge-fn pretty-print]
  ;; Client disconnects present as generic IOExceptions from the
  ;; output writer (via stream-json), and we just log them at debug
  ;; level.  For now, after the first row, there's nothing we can do

      ;; Log origin and AST of incoming query
      (let [{:keys [origin query]} query-map]
        (log/infof "PDBQuery:%s:%s"
                   query-id (-> (sorted-map :origin origin :ast query)
                                json/generate-string))))

    (try
      (jdbc/with-transacted-connection scf-read-db
        (let [munge-fn (get-munge-fn entity version query-options url-prefix)
              {:keys [results-query count-query]}
              (-> remaining-query
                  coerce-from-json
                  (query->sql entity version query-options
                              (select-keys context [:log-queries :query-id])))
              query-error (promise)
              resp (http/streamed-response
                    buffer
