Commit d789650
authored
node: stream reconciliation considers miniblock candidates (#4572)
# Fix stream reconciliation to handle stuck miniblock candidates
## Problem
Stream reconciliation could fail in edge cases where miniblock
candidates were registered on-chain but never promoted locally. This
occurred in two scenarios:
1. Non-replicated streams (replication factor = 1): When a node sent the
miniblock candidate registration transaction but missed the stream
updated event, the candidate remained unpromoted. With no remotes to
reconcile from, the stream became permanently stuck.
2. All replicas missing events: When all replicas of a stream missed the
stream update event, none promoted their candidates. Even though remotes
existed, reconciliation would fetch data unnecessarily instead of using
the locally available candidate. If none of the replicas promoted the
candidate the stream became permanently stuck.
## Solution
Added tryPromoteLocalCandidate() helper method that:
- Attempts to read and promote local miniblock candidates
- Properly distinguishes between NOT_FOUND (expected) and critical
errors (database failures)
- Returns clear success/failure states via (bool, error) tuple
- Prevents unnecessary network operations when local data is available
Integrated candidate promotion checks at two key points:
1. Before failing with no remotes (stream_reconciler.go:179-196) - Tries
to promote local candidate before giving up
2. When 1 miniblock behind (stream_reconciler.go:218-232) -
Opportunistically promotes candidate before fetching from remotes
## Changes
- stream_reconciler.go:
- Added tryPromoteLocalCandidate() method with proper error handling
- Updated two reconciliation paths to check for local candidates
- Fixed silent error handling bug (was using _ to ignore all errors)
- Improved error messages and comments
- stream_reconciler_test.go:
- Added TestReconciler_NoRemotesNoCandidateFails to verify error
handling
- All existing tests continue to pass (15 total)1 parent 0f1de29 commit d789650
File tree
2 files changed
+111
-1
lines changed- core/node/events
2 files changed
+111
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
178 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
179 | 197 | | |
180 | 198 | | |
181 | 199 | | |
| |||
197 | 215 | | |
198 | 216 | | |
199 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
200 | 234 | | |
201 | 235 | | |
202 | 236 | | |
| |||
234 | 268 | | |
235 | 269 | | |
236 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
237 | 301 | | |
238 | 302 | | |
239 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
| 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 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
0 commit comments