Skip to content

Commit da80013

Browse files
author
Matt Kafonek
authored
reduce error spam when file subscribe gives inconsistent state (#199)
* reduce error spam when file subscribe gives inconsistent state * changelog * Delete
1 parent 2fb1861 commit da80013

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ For pre-1.0 releases, see [0.0.35 Changelog](https://github.com/noteable-io/orig
88

99
## [Unreleased]
1010

11+
### [1.1.5] - 2023-11-06
12+
### Fixed
13+
- Try to reduce error spam when file subscribe replies return inconsistent state events
14+
1115
### [1.1.4] - 2023-10-23
1216
### Added
1317
- Programmatically adjust Space, Project, and Notebook/File visibility (e.g. `private`, `open`, `public`)

origami/clients/rtu.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ def __init__(
310310
# An inconsistent state event means the Notebook was updated in a way that "broke" Delta
311311
# history, and the RTUClient needs to pull in the seed notebook and re-apply deltas from
312312
# a "new" current version id in order to catch up
313+
#
314+
# However if we get several inconsistent state events (say from getting them on file
315+
# resubscribe), we'll call catastrophic_failure to let the application handle tear-down
316+
self.inconsistent_state_event_count = 0
313317
self.register_rtu_event_callback(
314318
rtu_event=InconsistentStateEvent, fn=self.on_inconsistent_state_event
315319
)
@@ -634,6 +638,10 @@ async def on_inconsistent_state_event(self, msg: InconsistentStateEvent):
634638
the least, to stop getting new deltas in. Then we need to figure out what the new current
635639
version id is, and pull down seed notebook, and then resubscribe to file channel.
636640
"""
641+
if self.inconsistent_state_event_count >= 3:
642+
logger.warning("Calling catastrophic failure after 3 inconsistent state events")
643+
return await self.catastrophic_failure()
644+
637645
logger.info("Received inconsistent state event, resetting NotebookBuilder")
638646
# There's the chance for some gnarly but rare edge cases here that would probably take a
639647
# serious amount of thinking and logic to handle. Basically, what happens if new Deltas
@@ -647,6 +655,7 @@ async def on_inconsistent_state_event(self, msg: InconsistentStateEvent):
647655
await self.file_unsubscribe()
648656
await self.load_seed_notebook()
649657
await self.send_file_subscribe()
658+
self.inconsistent_state_event_count += 1
650659

651660
async def _on_delta_recv(self, msg: NewDeltaEvent):
652661
"""

0 commit comments

Comments
 (0)