forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb4721f3
committed
Initialize TransactionState and user ID consistently at transaction start
If a failure happens when a transaction is starting between the momentthe transaction status is changed from TRANS_DEFAULT to TRANS_START andthe moment the current user ID and security context flags are fetchedvia GetUserIdAndSecContext(), or before initializing its basic fields,then those may get reset to incorrect values when the transactionaborts, leaving the session in an inconsistent state.One problem reported is that failing a starting transaction at the firstquery of a session could cause several kinds of system crashes on thefollow-up queries.In order to solve that, move the initialization of the transaction statefields and the call of GetUserIdAndSecContext() in charge of fetchingthe current user ID close to the point where the transaction status isswitched to TRANS_START, where there cannot be any error triggeredin-between, per an idea of Tom Lane. This properly ensures that thecurrent user ID, the security context flags and that the basic fields ofTransactionState remain consistent even if the transaction fails whilestarting.Reported-by: Richard GuoDiagnosed-By: Richard GuoAuthor: Michael PaquierReviewed-by: Tom LaneDiscussion:https://postgr.es/m/CAN_9JTxECSb=pEPcb0a8d+6J+bDcOZ4=DgRo_B7Y5gRHJUM=Rw@mail.gmail.comBackpatch-through: 9.41 parent3be97b9 commitb4721f3
1 file changed
+26
-22
lines changedLines changed: 26 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1809 | 1809 |
| |
1810 | 1810 |
| |
1811 | 1811 |
| |
1812 |
| - | |
1813 |
| - | |
1814 |
| - | |
1815 |
| - | |
1816 |
| - | |
1817 |
| - | |
| 1812 | + | |
| 1813 | + | |
1818 | 1814 |
| |
1819 | 1815 |
| |
1820 |
| - | |
1821 |
| - | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
1822 | 1820 |
| |
1823 | 1821 |
| |
1824 | 1822 |
| |
1825 | 1823 |
| |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
1826 | 1844 |
| |
1827 | 1845 |
| |
1828 | 1846 |
| |
| |||
1909 | 1927 |
| |
1910 | 1928 |
| |
1911 | 1929 |
| |
1912 |
| - | |
1913 |
| - | |
1914 |
| - | |
1915 |
| - | |
1916 |
| - | |
1917 |
| - | |
1918 |
| - | |
1919 |
| - | |
1920 |
| - | |
1921 |
| - | |
1922 |
| - | |
1923 |
| - | |
1924 |
| - | |
1925 |
| - | |
1926 | 1930 |
| |
1927 | 1931 |
| |
1928 | 1932 |
| |
|
0 commit comments
Comments
(0)