如何找出导致集群重启的错误查询?

How to find out the bad query that resulted into cluster restart?

如何从查询控制台找到可能的查询?

我知道时间段。

它在历史仪表板中不像在历史仪表板中那样可用。我只能看到最近 10 分钟的 运行 长查询。

也许我可以获得正确的 URI 来探索应用程序服务或计量数据?

如果您想查看在查询控制台中执行了哪些查询,请检查该时间范围内的 8000_AccessLog.txt 条目并查找 POST /qconsole/endpoints/evaler.xqy端点。

例如:

::1 - admin [20/Jun/2020:18:51:34 -0400] "POST /qconsole/endpoints/evaler.xqy?qid=4765025502384248875&dbid=10248170186042536325&sid=11969990273495629802&crid=6539177331&querytype=xquery&action=eval&cache=1592693494327 HTTP/1.1" 200 226 "http://localhost:8000/qconsole/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"

抓取qid(上例中为4765025502384248875

然后您可以通过构建具有该 ID 的 URI 在应用服务数据库中找到该查询:

doc("/queries/4765025502384248875.txt")

方法一:

  1. Check the server restart timestamp in the $Logs/ErrorLog.txt
  2. Assuming the original query was executed in qconsole, then get the $qid in the $Logs/8000_RequestLog.txt based on step 1 timestamps. e.g below $qid is 10831783099673334040

"url":"/qconsole/endpoints/evaler.xqy?qid=10831783099673334040&dbid=

  1. Execute below XQuery against the App-Services database:
declare namespace qconsole="http://marklogic.com/appservices/qconsole";
declare function local:query-history($qid as xs:unsignedLong)
{
  for $doc in doc()
  where $doc/qconsole:history/qconsole:query[qconsole:id = $qid]
  return base-uri($doc)
};
local:query-history(10831783099673334040);

以上将检索与 $qid 关联的历史 URI。历史文档将为您提供时间戳、内容……等 qconsole 历史记录的细分。

方法二:

You can view the query history dropdown ( little clock ) in the qconsole as below. It gives you the timestamp and the query details.