forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit48d67fd
committed
Fix race condition in psql \e's detection of file modification.
psql's editing commands decide whether the user has edited the fileby checking for change of modification timestamp. This is probablyfine for a pre-existing file, but with a temporary file that iscreated within the command, it's possible for a fast typist tosave-and-exit in less than the one-second granularity of stat(2)timestamps. On Windows FAT filesystems the granularity is evenworse, 2 seconds, making the race a bit easier to hit.To fix, try to set the temp file's mod time to be two seconds ago.It's unlikely this would fail, but then again the race conditionitself is unlikely, so just ignore any error.Also, we might as well check the file size as well as its mod time.While this is a difficult bug to hit, it still seems worthback-patching, to ensure that users' edits aren't lost.Laurenz Albe, per gripe from Jacob Champion; based on fix suggestionsfrom Jacob and myselfDiscussion:https://postgr.es/m/0ba3f2a658bac6546d9934ab6ba63a805d46a49b.camel@cybertec.at1 parentf52c5d6 commit48d67fd
1 file changed
+24
-3
lines changedLines changed: 24 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| 13 | + | |
13 | 14 |
| |
14 | 15 |
| |
15 | 16 |
| |
| |||
3709 | 3710 |
| |
3710 | 3711 |
| |
3711 | 3712 |
| |
3712 |
| - | |
3713 | 3713 |
| |
3714 | 3714 |
| |
3715 | 3715 |
| |
| |||
3734 | 3734 |
| |
3735 | 3735 |
| |
3736 | 3736 |
| |
| 3737 | + | |
3737 | 3738 |
| |
3738 | 3739 |
| |
3739 | 3740 |
| |
3740 | 3741 |
| |
3741 | 3742 |
| |
3742 | 3743 |
| |
3743 |
| - | |
3744 | 3744 |
| |
3745 | 3745 |
| |
3746 | 3746 |
| |
| |||
3790 | 3790 |
| |
3791 | 3791 |
| |
3792 | 3792 |
| |
| 3793 | + | |
| 3794 | + | |
| 3795 | + | |
| 3796 | + | |
| 3797 | + | |
| 3798 | + | |
| 3799 | + | |
| 3800 | + | |
| 3801 | + | |
| 3802 | + | |
| 3803 | + | |
| 3804 | + | |
| 3805 | + | |
| 3806 | + | |
| 3807 | + | |
| 3808 | + | |
| 3809 | + | |
| 3810 | + | |
3793 | 3811 |
| |
3794 | 3812 |
| |
3795 | 3813 |
| |
| |||
3809 | 3827 |
| |
3810 | 3828 |
| |
3811 | 3829 |
| |
3812 |
| - | |
| 3830 | + | |
| 3831 | + | |
| 3832 | + | |
| 3833 | + | |
3813 | 3834 |
| |
3814 | 3835 |
| |
3815 | 3836 |
| |
|
0 commit comments
Comments
(0)