You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Andres de la Peña (Jira)" <ji...@apache.org> on 2021/09/09 15:07:00 UTC

[jira] [Commented] (CASSANDRA-16938) Missed wait latencies in the output of `nodetool tpstats -F`

    [ https://issues.apache.org/jira/browse/CASSANDRA-16938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17412633#comment-17412633 ] 

Andres de la Peña commented on CASSANDRA-16938:
-----------------------------------------------

The proposed patch reverts the conversion from {{Double[]}} to {{String[]}} in {{TpStatsHolder}} and uses {{jackson-mapper-asl}} instead of {{json-simple}} to generate the json output:
||PR||CI||
|[4.0|https://github.com/apache/cassandra/pull/1190]|[j8|https://app.circleci.com/pipelines/github/adelapena/cassandra/837/workflows/494afd37-92b7-4127-9626-40cbc279a90c] [j11|https://app.circleci.com/pipelines/github/adelapena/cassandra/837/workflows/b8fee35e-5b60-4590-80b6-ffa53858b741]​|
|[trunk|https://github.com/apache/cassandra/pull/1191]|[j8|https://app.circleci.com/pipelines/github/adelapena/cassandra?branch=16938-trunk] [j11|https://app.circleci.com/pipelines/github/adelapena/cassandra/838/workflows/1ec0b51b-eb8d-4f55-b9d6-7b6d06dcce45]​|

All praise to [~dimitarndimitrov] who originally found the problem with {{json-simple}} and wrote the changes for {{StatsPrinter}}. The changes in {{TpStatsHolder}} and the new tests are mine.

> Missed wait latencies in the output of `nodetool tpstats -F`
> ------------------------------------------------------------
>
>                 Key: CASSANDRA-16938
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-16938
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tool/nodetool
>            Reporter: Andres de la Peña
>            Assignee: Andres de la Peña
>            Priority: Normal
>
> The output of {{nodetool tpstats -F json}} always prints an empty map for {{WaitLatencies}}:
> {code}
> $ nodetool tpstats -F json
> ..."WaitLatencies":{},...
> {code}
> The same happens with yaml output:
> {code}
> $ nodetool tpstats -F yaml
> ...
> WaitLatencies: {}
> ...
> {code}
> This happens because [this cast|https://github.com/apache/cassandra/blob/cassandra-4.0.1/src/java/org/apache/cassandra/tools/nodetool/stats/TpStatsHolder.java#L61-L63] silently fails inside a try-catch with an empty catch block:
> {code}
> String[] strValues = (String[]) Arrays.stream(probe.metricPercentilesAsArray(probe.getMessagingQueueWaitMetrics(entry.getKey())))
>                                       .map(D -> D.toString())
>                                       .toArray();
> {code}
> When we would need something like:
> {code}
> String[] strValues = Arrays.stream(probe.metricPercentilesAsArray(probe.getMessagingQueueWaitMetrics(entry.getKey())))
>                            .map(Object::toString)
>                            .toArray(String[]::new);
> {code}
> This conversion from {{Double[]}} to {{String[]}} was introduced during CASSANDRA-16230. I think that conversion was done trying to work around a malformed JSON output detected in [the new tests|https://github.com/apache/cassandra/blob/cassandra-4.0.1/test/unit/org/apache/cassandra/tools/NodeToolTPStatsTest.java#L158] added by that ticket. Without the conversion the output would be something like:
> {code}
> $ nodetool tpstats -F json
> ..."WaitLatencies":{"READ_RSP":[Ljava.lang.Double;@398dada8,...
> {code}
> That's because {{json-simple}} doesn't handle well arrays. I think that instead of converting the array of doubles to an array of strings we can simply use {{jackson-mapper-asl}} to print the proper array.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org