- Notifications
You must be signed in to change notification settings - Fork5k
Commit80b727e
committed
Use the same cmd_context throughout a walsender's lifetime.
exec_replication_command created a cmd_context to work in andthen deleted it on exit. This is pretty dangerous becausesome replication commands start/finish transactions. In thewake of commit1afe31f, that could lead to re-selecting aCurrentMemoryContext that's already been deleted, leading tohilarity such as a memory context that is its own parent.To fix, let's make the cmd_context persist acrossexec_replication_command calls; instead of deleting it, we'll justreset it each time. In this way it retains the same identity andthere's no problem if transaction abort restores it as the workingcontext. It probably even saves a few microseconds to do this.This fix also ensures that exec_replication_command returns to thecaller (PostgresMain) with the same context active that had beenwhen it was called (probably MessageContext). The previouscoding could get that wrong too.Reported-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>Author: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/CAO6_XqoJA7-_G6t7Uqe5nWF3nj+QBGn4F6Ptp=rUGDr0zo+KvA@mail.gmail.com1 parent5ec8b01 commit80b727e
File tree
2 files changed
+51
-9
lines changed- src
- backend/replication
- test/subscription/t
2 files changed
+51
-9
lines changedLines changed: 33 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1973 | 1973 |
| |
1974 | 1974 |
| |
1975 | 1975 |
| |
1976 |
| - | |
1977 |
| - | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
1978 | 1980 |
| |
1979 | 1981 |
| |
1980 | 1982 |
| |
| |||
2003 | 2005 |
| |
2004 | 2006 |
| |
2005 | 2007 |
| |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
2006 | 2023 |
| |
2007 |
| - | |
2008 |
| - | |
2009 |
| - | |
2010 |
| - | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
2011 | 2032 |
| |
2012 | 2033 |
| |
2013 | 2034 |
| |
| |||
2020 | 2041 |
| |
2021 | 2042 |
| |
2022 | 2043 |
| |
2023 |
| - | |
| 2044 | + | |
2024 | 2045 |
| |
2025 | 2046 |
| |
2026 | 2047 |
| |
| |||
2180 | 2201 |
| |
2181 | 2202 |
| |
2182 | 2203 |
| |
2183 |
| - | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
2184 | 2208 |
| |
2185 |
| - | |
| 2209 | + | |
2186 | 2210 |
| |
2187 | 2211 |
| |
2188 | 2212 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
477 | 477 |
| |
478 | 478 |
| |
479 | 479 |
| |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
480 | 498 |
| |
481 | 499 |
| |
482 | 500 |
| |
|
0 commit comments
Comments
(0)