forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit501cfd0
committed
Fix resource leak when a FDW's ForeignAsyncRequest function fails
If an error is thrown after calling CreateWaitEventSet(), the memoryof a WaitEventSet is free'd as it's allocated in the short-livedmemory context, but the file descriptor (on epoll- or kqueue-basedsystems) or handles (on Windows) that it contains are leaked.Use PG_TRY-FINALLY to ensure it gets freed. (On master, I will apply abetter fix, using ResourceOwners to track the WaitEventSet, but that'snot backpatchable.)The added test doesn't check for leaking resources, so it passed evenbefore this commit. But at least it covers the code path.In the passing, fix misleading comment on what the 'nevents' argumentto WaitEventSetWait means.Report by Alexander Lakhin, analysis and suggestion for the fix by TomLane. Fixes bug #17828. Backpatch to v14 where async execution wasintroduced, but master gets a different fix.Discussion:https://www.postgresql.org/message-id/17828-122da8cba23236be@postgresql.orgDiscussion:https://www.postgresql.org/message-id/472235.1678387869@sss.pgh.pa.us1 parent1b6da28 commit501cfd0
File tree
3 files changed
+50
-29
lines changed- contrib/postgres_fdw
- expected
- sql
- src/backend/executor
3 files changed
+50
-29
lines changedLines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10825 | 10825 |
| |
10826 | 10826 |
| |
10827 | 10827 |
| |
| 10828 | + | |
| 10829 | + | |
| 10830 | + | |
| 10831 | + | |
| 10832 | + | |
| 10833 | + | |
| 10834 | + | |
10828 | 10835 |
| |
10829 | 10836 |
| |
10830 | 10837 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3603 | 3603 |
| |
3604 | 3604 |
| |
3605 | 3605 |
| |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
3606 | 3612 |
| |
3607 | 3613 |
| |
3608 | 3614 |
| |
|
Lines changed: 37 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1025 | 1025 |
| |
1026 | 1026 |
| |
1027 | 1027 |
| |
| 1028 | + | |
1028 | 1029 |
| |
1029 |
| - | |
1030 |
| - | |
1031 |
| - | |
1032 |
| - | |
1033 |
| - | |
1034 |
| - | |
| 1030 | + | |
1035 | 1031 |
| |
1036 |
| - | |
| 1032 | + | |
| 1033 | + | |
1037 | 1034 |
| |
1038 |
| - | |
1039 |
| - | |
1040 |
| - | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
1041 | 1040 |
| |
1042 |
| - | |
1043 |
| - | |
1044 |
| - | |
1045 |
| - | |
1046 |
| - | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
1047 | 1068 |
| |
1048 | 1069 |
| |
1049 | 1070 |
| |
1050 |
| - | |
1051 | 1071 |
| |
1052 |
| - | |
1053 |
| - | |
1054 |
| - | |
1055 |
| - | |
1056 |
| - | |
1057 |
| - | |
1058 |
| - | |
1059 |
| - | |
1060 |
| - | |
1061 |
| - | |
1062 |
| - | |
1063 |
| - | |
1064 |
| - | |
| 1072 | + | |
1065 | 1073 |
| |
1066 | 1074 |
| |
1067 | 1075 |
| |
|
0 commit comments
Comments
(0)