forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit248c3a9
committed
Clean up error handling in pg_basebackup's walmethods.c.
The error handling here was a mess, as a result of a fundamentallybad design (relying on errno to keep its value much longer than issafe to assume) as well as a lot of just plain sloppiness, both asto noticing errors at all and as to reporting the correct errno.Moreover, the recent addition of LZ4 compression broke thingscompletely, because liblz4 doesn't use errno to report errors.To improve matters, keep the error state in the DirectoryMethodData orTarMethodData struct, and add a string field so we can handle casesthat don't set errno. (The tar methods already had a version of this,but it can be done more efficiently since all these cases use aconstant error string.) Make the dir and tar methods handle errorsin basically identical ways, which they didn't before.This requires copying errno into the state struct in a lot of places,which is a bit tedious, but it has the virtue that we can get rid ofad-hoc code to save and restore errno in a number of places ... notto mention that it fixes other places that should've saved/restorederrno but neglected to.In passing, fix some pointlessly static buffers to be ordinarylocal variables.There remains an issue about exactly how to handle errors fromfsync(), but that seems like material for its own patch.While the LZ4 problems are new, all the rest of this is fixes forold bugs, so backpatch to v10 where walmethods.c was introduced.Patch by me; thanks to Michael Paquier for review.Discussion:https://postgr.es/m/1343113.1636489231@sss.pgh.pa.us1 parent3cac2c8 commit248c3a9
1 file changed
+169
-66
lines changed0 commit comments
Comments
(0)