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
30.1k stars 3.81k forks source link

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

Open sambhav-jain-16 opened 1 month ago

sambhav-jain-16 commented 1 month ago

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: <empty>
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

blathers-crl[bot] commented 1 month ago

Hi @sambhav-jain-16, please add branch-* labels to identify which branch(es) this C-bug affects.

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

sambhav-jain-16 commented 1 month ago

Assigned this as P2 since this is not a critical bug rather an improvement.