Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: COPY FROM tests are broken #18352

Closed
nvanbenschoten opened this issue Sep 7, 2017 · 11 comments · Fixed by #53511
Closed

sql: COPY FROM tests are broken #18352

nvanbenschoten opened this issue Sep 7, 2017 · 11 comments · Fixed by #53511
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Milestone

Comments

@nvanbenschoten
Copy link
Member

nvanbenschoten commented Sep 7, 2017

Both TestCopyOne and TestCopyInProgress were previously skipped because of lib/pq#558, but this issue has since been fixed. With the t.Skip calls removed, though, the tests both fail with timeout errors. I'm not sure if this is a test error or a real error (in cockroach or in lib/pq), but we should investigate.

@nvanbenschoten nvanbenschoten added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Sep 7, 2017
@nvanbenschoten nvanbenschoten added this to the 1.1 milestone Sep 7, 2017
nvanbenschoten added a commit to nvanbenschoten/cockroach that referenced this issue Sep 7, 2017
@maddyblue
Copy link
Contributor

maddyblue commented Sep 13, 2017

These problems are due to race conditions in lib/pq. I'm becoming increasingly convinced that we should move off of lib/pq completely, so I'm inclined to not fix these bugs, but instead use our time to migrating to pgx. If anyone cares I've put some of the work at https://github.com/mjibson/pq/tree/copy-race

@nvanbenschoten
Copy link
Member Author

Should we disable COPY FROM for now then?

@maddyblue
Copy link
Contributor

No COPY works fine in cockroach if you use psql. And it's fine with lib/pq as long as you don't try and do the weird things the tests are testing for. But these tests should have been added to lib/pq years ago when they first added COPY support, but they weren't. Cockroach is fine.

@nvanbenschoten
Copy link
Member Author

So what do we do here? We should either open another issue in lib/pq and try upstreaming that race fix ourselves or adjust these tests so that they don't depend on the "weird things" in lib/pq. Can we just pass in the SQL string directly?

@maddyblue
Copy link
Contributor

We can't pass in the SQL string directly because COPY is a specific mode. lib/pq implements copy by having the user "pretend" to do a transaction and execute it, but intercepts this call so it's not in the normal txn/exec flow. If it were me, we would spend 0 effort fixing lib/pq and leave this test as is for now, and instead begin working on a move to pgx (or a custom driver since pgx also doesn't quite do everything we need, but we can get it there). I no longer think it is a good use of our time to contribute to lib/pq.

@nvanbenschoten
Copy link
Member Author

So are these tests even testing Cockroach or are they just testing lib/pq? If they are only testing lib/pq then shouldn't we open up an issue in lib/pq and get rid of the tests? If they are testing Cockroach then we should find a way to circumvent lib/pq and still test the same behavior, otherwise, we're not fully verifying that "Cockroach is fine".

@maddyblue
Copy link
Contributor

They would be testing cockroach if lib/pq weren't broken. That is, they attempt to test cockroach's connection state machine to verify it can't do the things the tests test. But lib/pq's state machine is broken instead, so we can't even get there. Yes, we should open up a lib/pq bug. I'll do that sometime.

I agree we should circumvent lib/pq so we can actually test cockroach. I think we should switch to pgx to do this.

@petermattis
Copy link
Collaborator

Couldn't we hit similar problems with the protocol implementation in pgx? Perhaps we should fork/extend either pq or pgx for the purpose of allowing flexible testing of our COPY protocol implementation.

@maddyblue
Copy link
Contributor

Yes, that is possible. I've already done an initial implementation of our own driver and a pgx fork. Still prototyping both before I can figure out which one makes more sense.

@danhhz danhhz modified the milestones: 1.1, 1.2 Sep 19, 2017
@vivekmenezes vivekmenezes modified the milestones: 2.0, 2.1 Mar 5, 2018
@knz knz added this to To do in DB Server & Security via automation Apr 28, 2018
@andreimatei
Copy link
Contributor

As it stands, using pgx for copy from doesn't work because pgx sends queries like copy "t" ( "x" ) from stdin binary; and we don't parse that - we don't support the binary encoding for copy values :|.

@maddyblue
Copy link
Contributor

We can also fix these tests by using the pgproto package from pgx to manually send packets in the order that we want. This will allow us to remove the racey lib/pq code and correctly test our COPY implementation for adversarial input.

@nstewart nstewart added the S-3-productivity Severe issues that impede the productivity of CockroachDB developers. label Sep 18, 2018
@knz knz modified the milestones: 2.1, 2.2 Oct 5, 2018
@piyush-singh piyush-singh moved this from To do to 2.2 Release in DB Server & Security Jan 15, 2019
@piyush-singh piyush-singh removed this from 19.2 Release in DB Server & Security May 16, 2019
@jordanlewis jordanlewis removed the S-3-productivity Severe issues that impede the productivity of CockroachDB developers. label May 17, 2019
@jordanlewis jordanlewis moved this from Triage to Lower priority backlog in [DEPRECATED] Old SQLExec board. Don't move stuff here May 17, 2019
@asubiotto asubiotto moved this from Lower priority backlog to Unclear in [DEPRECATED] Old SQLExec board. Don't move stuff here Apr 2, 2020
@asubiotto asubiotto moved this from Unclear to [TENT] SQL Features in [DEPRECATED] Old SQLExec board. Don't move stuff here Apr 2, 2020
craig bot pushed a commit that referenced this issue Aug 28, 2020
53368: docgen: update template for http docs r=mjibson a=mjibson



53511: sql: unskip and move some COPY tests to pgtest r=mjibson a=mjibson

Now that we have pgtest we can much more easily test weird message
ordering without dealing with lib/pq problems.

Fixes #18352

Release note: None

Release justification: Non-production code changes

53581: opt: push limit into unconstrained partial index scan r=RaduBerinde a=mgartner

This commit updates the PushLimitIntoConstrainedScan rule to push
limits into unconstrained partial index scans. The rule has been renamed
to PushLimitIntoFilteredScan to better reflect this new logic.

Release justification: This is a low-risk update to new functionality,
partial indexes.

Fixes #50828

Release note: None

Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
@craig craig bot closed this as completed in 19bb0a9 Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

9 participants