Commit 83be468
committed
fix: detect Cosmos DB on restart, not just initial sync
isCosmosDb was only set during getSnapshotLsn() which runs on initial
sync. After restart (snapshot already done), the flag stayed false,
causing the stream to open with MongoDB-only features that Cosmos DB
rejects: $changeStreamSplitLargeEvent, showExpandedEvents, db.watch().
Extract detection into a reusable detectCosmosDb() method (idempotent,
runs hello once per ChangeStream instance). Call it at the top of both
initReplication() and streamChangesInternal() so detection happens
before any change stream operation, regardless of whether initial sync
runs.
This was a production-blocking bug: every service restart after initial
sync would crash the replication loop with PSYNC_S1346.
Result: 25/26 Cosmos DB tests pass. The one remaining failure is
"resume after restart" on storage v2 only — a storage-version-specific
issue unrelated to detection.1 parent 74798d4 commit 83be468
1 file changed
Lines changed: 21 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
250 | | - | |
251 | | - | |
252 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
253 | 254 | | |
254 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
255 | 261 | | |
256 | | - | |
257 | 262 | | |
258 | | - | |
259 | 263 | | |
260 | 264 | | |
261 | 265 | | |
| |||
271 | 275 | | |
272 | 276 | | |
273 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
274 | 287 | | |
275 | 288 | | |
276 | 289 | | |
| |||
781 | 794 | | |
782 | 795 | | |
783 | 796 | | |
| 797 | + | |
784 | 798 | | |
785 | 799 | | |
786 | 800 | | |
| |||
923 | 937 | | |
924 | 938 | | |
925 | 939 | | |
| 940 | + | |
926 | 941 | | |
927 | 942 | | |
928 | 943 | | |
| |||
0 commit comments