Skip to content

Error in middle of structure load can cause :epipe error and takes process down #721

@nulian

Description

@nulian

Elixir version

1.18.4

Database and Version

tried in mysql 8.0 and 8.4

Ecto Versions

ecto_sql 3.13.5

Database Adapter and Versions (postgrex, myxql, etc)

myxql

Current behavior

I made a repo with pipeline that uses the data I had the issue with and randomized column and table names. Because just simply having the single failing sql statement wont trigger it.

https://github.com/nulian/mysql-structure-load-error

You can see the error being trigger in the github workflow

When it executes the module that triggers the structure load that has the epipe error
When running the repo locally I get a little bit more like ** (EXIT from #PID<0.288.0>) shell process exited with reason: :epipe

mix run -e "ImportError.StructureLoader.load()"

Found the issue trigger mostly between these lines below in lib/ecto/adapters/myxql.ex

 Port.command(port, contents)
 # Use this as a signal to close the port since we cannot
 # send an exit command to mysql in batch mode
 Port.command(port, ";SELECT '__ECTO_EOF__';\n")

Guess the exit of the mysql client with the error triggers while it might still be pushing data in the background and then hard crashes the entire process. This guess is based on that if I remove all the sql statements after the invalid mysql statement then you get normal error tuple back with the error.

Expected behavior

On error show the original mysql error returned by mysql command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions