cockroachdb / cockroachdb/cockroach

sql: add more descriptive error message when import fails due to extra column

Open
#130,385 2 comments 0 reactions 0 assignees View on GitHub
A-import branch-master branch-release-23.1 branch-release-23.2 branch-release-24.1 branch-release-24.2 C-enhancement E-quick-win O-testcluster P-3 T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

While importing workload fixture on drt-ldr cluster, we found the import failing with the log line
```
drtprod ssh drt-ldr1:1 "./cockroach workload init ycsb --workload=A --insert-count=1000 --families=false {pgurl:1}"
1240909 06:49:55.467805 1 workload/cli/run.go:659 I-] 1 random seed: 14966490948245196829
I240909 06:49:55.476569 1 ccl/workloadccl/fixture.go:318 [-] 2 starting import of 1 tables
Error: importing fixture: importing table usertable: pq: insert row: unable to encode table value: ‹nil>
Error: COMMAND_
_PROBLEM: exit status 1
(1) Node 1. Command with error:
| •/cockroach workload init ycsb --workload=A --insert-count=1000 --families=false {pgurl:1}
stdout:
stderr: I240909 06:49:55.467805 1 workload/cli/run.go:659 I-1 1 random seed: 14966490948245196829
1240909 06:49:55.476569 1 ccl/workloadccl/fixture.go:318 I-] 2 starting import of 1 tables
I Error: importing fixture: importing table usertable: pq: insert row: unable to encode table value: ‹nil>
Wraps: (2) COMMAND_PROBLEM
Wraps: (3) exit status 1
Error types: (1) *hintdetail.withDetail (2) errors.Cmd (3) *exe.ExitError
```

Although we were able to figure out the reason for this error due to improper steps of setting it up, it was impossible for someone trying to debug using the above log line without contacting the sql team.

**To Reproduce**

```

./cockroach workload init ycsb --workload=A --insert-count=1000 --families=false

# in first shell
ALTER TABLE ycsb.public.usertable ADD COLUMN expired_at TIMESTAMPTZ NOT NULL DEFAULT now() + '30 minutes';
TRUNCATE TABLE ycsb.public.usertable;

# in second shell
./cockroach workload init ycsb --workload=A --insert-count=1000 --families=false

```

**Expected behavior**
A better log line which states which column/value was failing and what are the actual reason.

**Additional data / screenshots**
Screenshot 2024-09-09 at 12 27 24 PM

Screenshot 2024-09-09 at 12 27 05 PM

Jira issue: CRDB-42021

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.