MySQL Load: Combine sql and exit signal in one port command#724
Merged
greg-rychlewski merged 4 commits intoelixir-ecto:masterfrom Apr 2, 2026
Merged
MySQL Load: Combine sql and exit signal in one port command#724greg-rychlewski merged 4 commits intoelixir-ecto:masterfrom
greg-rychlewski merged 4 commits intoelixir-ecto:masterfrom
Conversation
josevalim
reviewed
Apr 2, 2026
lib/ecto/adapters/myxql.ex
Outdated
| # send an exit command to mysql in batch mode | ||
| Port.command(port, ";SELECT '__ECTO_EOF__';\n") | ||
| exit_signal = ";SELECT '__ECTO_EOF__';\n" | ||
| Port.command(port, [contents, exit_signal]) |
Member
There was a problem hiding this comment.
Another option is to use messages to talk to the port, instead of using command. The message is asynchronous and always succeed:
port ! {self(), {:command, contents}}
port ! {self(), {:command, ";SELECT '__ECTO_EOF__';\n"}}
We will know if it fails when we collect the output below. This way there is no chance we fail prematurely on Port.command. WDYT?
Member
Author
There was a problem hiding this comment.
nice!
btw I'm not sure if this is expected or not, but when I used port ! ... instead of send(port, ...) I got an error complaining port/1 is not a function. just thought I would let you know in case it's an issue you are not expecting
Member
There was a problem hiding this comment.
I used the Erlang syntax cause I was writing some Erlang earlier today 😅 It is all good!
josevalim
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This should catch the case where we call
Port.commandthe second time after the port has closed. Our previous fix caught the case where we have an issue with the firstPort.commandcall sending data packets after it has been closed