-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
cli: Support nodelocal file upload in CLI #42966
Conversation
There's two things that still need to be changed in this PR:
|
@@ -112,6 +118,7 @@ func (f *fileUploadMachine) run(ctx context.Context) error { | |||
err := f.c.run(ctx) | |||
_ = f.writeToFile.Close() | |||
if err != nil { | |||
f.failureCleanup() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about if f.writeError has an error? Can/should the API be changed so there's only 1 possible error produced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will think about restructuring this. However, since this is on two sides of an io.Pipe
, we still need to capture either side's failures.
pkg/cli/nodelocal.go
Outdated
if err != nil { | ||
return err | ||
} | ||
_, err = stmt.Exec([]driver.Value{string(send[:n])}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you just exec without casting to a string? that'd save a memory copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I exec as just bytes, it prints the string representation of the bytes to stdin, which gets received that way on the other side. I'm unsure how to receive that on the other side, and convert them back to strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried stmt.Exec(send[:n])
? I thought that's how lib/pq's Copy was supposed to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm doesn't seem like it. I'll look into how we can structure this better, make use of some of the better suited APIs.
Two changes:
|
This change uses the changes made in cockroachdb#42748, which enabled COPY to upload files. We are now implementing the CLI to include a new command: `nodelocal upload`. This command takes in a source file to upload, and a destination filename. It will then use the COPY command to upload the file and drop it on the gateway node's local file system, at: `externalIODir/destination/filename` This PR also includes the CLI testing for this feature as well as a bug fix for the previous PR cockroachdb#42748: - If writing the file fails, we do not delete the file that was created. This PR fixes that. Release note (cli change): Adds a nodelocal command that can be used to upload file: `cockroach nodelocal upload location/of/file destination/of/file`
bors r+ |
42966: cli: Support nodelocal file upload in CLI r=g3orgia a=g3orgia This change uses the changes made in #42748, which enabled COPY to upload files. We are now implementing the CLI to include a new command: `nodelocal upload`. This command takes in a source file to upload, and a destination filename. It will then use the COPY command to upload the file and drop it on the gateway node's local file system, at: `externalIODir/destination/filename` This PR also includes the CLI testing for this feature as well as a bug fix for the previous PR #42748: - If writing the file fails, we do not delete the file that was created. This PR fixes that. Release note (cli change): Adds a nodelocal command that can be used to upload file: `cockroach nodelocal upload location/of/file destination/of/file` 42973: sql/mutations: stats histograms r=mjibson a=mjibson 43203: sqlmigrations: copy entries into new system.namespace in 20.1 r=arulajmani a=arulajmani In 20.1, CRDB started using a new system.namespace table that had an additional primary key column, `ParentSchemaID`. Previously, all namespace entries created before 20.1 could only be accessed through the old table. This patch migrates them over to the new `system.namespace` table. In the migration: - All databases (`parentID` = 0) are migrated over as is, with the `parentSchemaID` set to 0. - For every database, we add an entry for the `public` schema, which has the ID 29. - All tables (`parentID` != 0) are migrated over as is, with the `parentSchemaID` set to 29. Release note: none Co-authored-by: Georgia Hong <georgiah@cockroachlabs.com> Co-authored-by: Matt Jibson <matt.jibson@gmail.com> Co-authored-by: Arul Ajmani <arulajmani@gmail.com>
Build succeeded |
This change uses the changes made in #42748, which enabled
COPY to upload files. We are now implementing the CLI to include
a new command:
nodelocal upload
. This command takes in asource file to upload, and a destination filename. It will
then use the COPY command to upload the file and drop it
on the gateway node's local file system, at:
externalIODir/destination/filename
This PR also includes the CLI testing for this feature as
well as a bug fix for the previous PR #42748:
that was created. This PR fixes that.
Release note (cli change): Adds a nodelocal command
that can be used to upload file:
cockroach nodelocal upload location/of/file destination/of/file