forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1219823
committed
Add safeguards for pg_fsync() called with incorrectly-opened fds
On some platforms, fsync() returns EBADFD when opening a file descriptorwith O_RDONLY (read-only), leading ultimately now to a PANIC to preventdata corruption.This commit adds a new sanity check in pg_fsync() based on fcntl() tomake sure that we don't repeat again mistakes with incorrectly-set filedescriptors so as problems are detected at an early stage. Withoutthat, such errors could only be detected after running Postgres on aspecific supported platform for the culprit code path, which could takesome time before being found.b8e19b9 was a fix for such a problem,which got undetected for more than 5 years, anda586cc4 fixed anothersimilar issue.Note that the new check added works as well when fsync=off isconfigured, so as all regression tests would detect problems as long asassertions are enabled. fcntl() being not available on Windows, thenew checks do not happen there.Author: Michael PaquierReviewed-by: Mark DilgerDiscussion:https://postgr.es/m/20191009062640.GB21379@paquier.xyz1 parent080313f commit1219823
1 file changed
+38
-0
lines changedLines changed: 38 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
329 | 329 |
| |
330 | 330 |
| |
331 | 331 |
| |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
332 | 370 |
| |
333 | 371 |
| |
334 | 372 |
| |
|
0 commit comments
Comments
(0)