EyeSeeTea / d2-docker

GNU General Public License v3.0
9 stars 3 forks source link

[fix] [d2-docker commit] Make sure commit fails if pg_dump fails #121

Closed tokland closed 6 months ago

tokland commented 6 months ago

Issue: ??? (consult with Adrian)

Scenario: d2-docker commit IMAGE sometimes generates empty databases.

Reason: Sometimes (very infrequently), pg_dump fails (a real example: pg_dump: error: query failed: ERROR: could not open relation with OID 76698183) but d2-docker commit continues as if nothing happened. That's because the process involves a "pg_dump | gzip" pipe, and bash, by default, does not exit with an error if an intermediate command in a pipe fails.

Solution: Enable flag "pipefail" before executing the pipe.