cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
29.92k stars 3.78k forks source link

cockroach node status reports integer out of range #119038

Open sergeyshaykhullin opened 7 months ago

sergeyshaykhullin commented 7 months ago

Describe the problem

cockroach node status reports integer out of range

To Reproduce

sql.defaults.default_int_size = 4 cockroach node status --all --insecure

Expected behavior Returns output

Additional data / screenshots

cockroach node status --all --insecure
ERROR: integer out of range for type int4
SQLSTATE: 22003
Failed running "node status"

Environment:

Additional context What was the impact?

Add any other context about the problem here.

Jira issue: CRDB-35992

blathers-crl[bot] commented 7 months ago

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I was unable to automatically find someone to ping.

If we have not gotten back to your issue within a few business days, you can try the following:

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

annrpom commented 7 months ago

cc: @stevendanna

sergeyshaykhullin commented 1 month ago

23.2.8 still has this problem

image

stevendanna commented 1 month ago

My suspicion is the problem is when we sum the disk stats for the ranges. These could easily verflow when the default int size is 4:

    const rangesQuery = `
SELECT node_id AS id,
       sum((metrics->>'replicas.leaders')::DECIMAL)::INT AS replicas_leaders,
       sum((metrics->>'replicas.leaseholders')::DECIMAL)::INT AS replicas_leaseholders,
       sum((metrics->>'replicas')::DECIMAL)::INT AS ranges,
       sum((metrics->>'ranges.unavailable')::DECIMAL)::INT AS ranges_unavailable,
       sum((metrics->>'ranges.underreplicated')::DECIMAL)::INT AS ranges_underreplicated
FROM crdb_internal.kv_store_status
GROUP BY node_id`

    const statsQuery = `
SELECT node_id AS id,
       sum((metrics->>'livebytes')::DECIMAL)::INT AS live_bytes,
       sum((metrics->>'keybytes')::DECIMAL)::INT AS key_bytes,
       sum((metrics->>'valbytes')::DECIMAL)::INT AS value_bytes,
       sum(coalesce((metrics->>'rangekeybytes')::DECIMAL, 0))::INT AS range_key_bytes,
       sum(coalesce((metrics->>'rangevalbytes')::DECIMAL, 0))::INT AS range_value_bytes,
       sum((metrics->>'intentbytes')::DECIMAL)::INT AS intent_bytes,
       sum((metrics->>'sysbytes')::DECIMAL)::INT AS system_bytes
FROM crdb_internal.kv_store_status
GROUP BY node_id`

We should probably explicitly casting these to larger types.