cockroachdb / cockroachdb/cockroach
User with VIEWACTIVITY privilege gets error when activating statement diagnostics in DB Console
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
With a user with only VIEWACTIVITY privilege, I tried to Activate statement diagnostics and saw the error below:
```
There was an error activating statement diagnostics
Please try activating again. If the problem continues please reach out to customer support.
```
**To Reproduce**
1. Set up a local secure CockroachDB cluster (v23.2.0-beta.1 or v23.1.12)
```
mkdir certs my-safe-directory
cockroach cert create-ca --certs-dir=certs --ca-key=my-safe-directory/ca.key
cockroach cert create-node localhost $(hostname) --certs-dir=certs --ca-key=my-safe-directory/ca.key
cockroach cert create-client root --certs-dir=certs --ca-key=my-safe-directory/ca.key
cockroach cert create-client userviewactivity --certs-dir=certs --ca-key=my-safe-directory/ca.key
cockroach start-single-node --certs-dir=certs --listen-addr=localhost:36257 --sql-addr=localhost:26257 --http-addr=localhost:8080 --background
```
2. Open a `cockroach sql` shell
```
cockroach sql --certs-dir=certs --port=26257
```
3. In the sql shell as root run the following statements as setup:
```
CREATE USER userviewactivity WITH PASSWORD 'test';
GRANT SYSTEM VIEWACTIVITY TO userviewactivity;
DROP DATABASE IF EXISTS test1 CASCADE;
CREATE DATABASE test1; USE test1;
CREATE TABLE kv1 (k INT8 NOT NULL, v INT8 NULL, CONSTRAINT kv_pkey PRIMARY KEY (k ASC));
INSERT INTO kv1 VALUES (1,10), (2,20);
SELECT * from kv1;
```
4. Login to a DB Console as user `userviewactivity`
5. In the DB Console, navigate to the SQL Activity Statements page and find the statement
```
SELECT * from kv1
```
6. In the row for that statement, scroll all the way to the right and click the **Activate** button under the Diagnostics column.
7. In the **Activate statement diagnostics** dialog, select `Trace and collect diagnostics on the next statement execution`
8. Click **Activate** button.
9. Error message is displayed.
**Expected behavior**
No error message should be displayed. On the very right of the statement row, the **Activate** button is replaced by `Waiting...`
**Environment:**
- CockroachDB version v23.2.0-beta.1 and v23.1.12
- Server OS: mac
- Client app `cockroach sql`
**Additional context**
With a user with `VIEWACTIVITYREDACTED` privilege, the **Activate** button is not displayed.
Jira issue: CRDB-34230
Contributor guide
Assessment
This issue has not been assessed yet.