Commit 52dc3a3
committed
backup: fix race condition in starting compaction job
In #145930, scheduled compactions are blocked from running if another
compaction job is running for the schedule. However, it is currently
possible for there to be a race condition which results in a compaction
job being unable to find an incremental backup. Take the following
circumstance:
1. Compaction job A starts.
2. A scheduled backup B completes and begins considering whether a
compaction job should run. It fetches the current chain to its end time
and finds that it should run a compaction.
3. Compaction job A completes.
4. B starts a transaction to create the compaction job. Because A has
completed, it does not block the job from being created.
5. B creates a compaction job C that has a start time that is now
skipped due to A's completion.
6. When C is picked up by the job system, it resolves the backup chain
again, which now no longer has its start time and it fails.
This is resolved by opening a transaction before fetching the backup
chain to check for an already running compaction job.
Fixes: #149867, #147264
Release note: None1 parent d7ce141 commit 52dc3a3
1 file changed
+55
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
102 | 124 | | |
103 | 125 | | |
104 | 126 | | |
| |||
115 | 137 | | |
116 | 138 | | |
117 | 139 | | |
118 | | - | |
119 | 140 | | |
120 | 141 | | |
121 | 142 | | |
122 | | - | |
123 | | - | |
| 143 | + | |
| 144 | + | |
124 | 145 | | |
125 | 146 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 147 | + | |
135 | 148 | | |
136 | 149 | | |
137 | 150 | | |
| |||
171 | 184 | | |
172 | 185 | | |
173 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
174 | 190 | | |
175 | 191 | | |
176 | 192 | | |
| |||
931 | 947 | | |
932 | 948 | | |
933 | 949 | | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
934 | 977 | | |
935 | 978 | | |
936 | 979 | | |
0 commit comments