Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce error spam when file subscribe gives inconsistent state #199

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ For pre-1.0 releases, see [0.0.35 Changelog](https://github.com/noteable-io/orig

## [Unreleased]

### [1.1.5] - 2023-11-06
### Fixed
- Try to reduce error spam when file subscribe replies return inconsistent state events

### [1.1.4] - 2023-10-23
### Added
- Programmatically adjust Space, Project, and Notebook/File visibility (e.g. `private`, `open`, `public`)
Expand Down
9 changes: 9 additions & 0 deletions origami/clients/rtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ def __init__(
# An inconsistent state event means the Notebook was updated in a way that "broke" Delta
# history, and the RTUClient needs to pull in the seed notebook and re-apply deltas from
# a "new" current version id in order to catch up
#
# However if we get several inconsistent state events (say from getting them on file
# resubscribe), we'll call catastrophic_failure to let the application handle tear-down
self.inconsistent_state_event_count = 0
self.register_rtu_event_callback(
rtu_event=InconsistentStateEvent, fn=self.on_inconsistent_state_event
)
Expand Down Expand Up @@ -634,6 +638,10 @@ async def on_inconsistent_state_event(self, msg: InconsistentStateEvent):
the least, to stop getting new deltas in. Then we need to figure out what the new current
version id is, and pull down seed notebook, and then resubscribe to file channel.
"""
if self.inconsistent_state_event_count >= 3:
logger.warning("Calling catastrophic failure after 3 inconsistent state events")
return await self.catastrophic_failure()

logger.info("Received inconsistent state event, resetting NotebookBuilder")
# There's the chance for some gnarly but rare edge cases here that would probably take a
# serious amount of thinking and logic to handle. Basically, what happens if new Deltas
Expand All @@ -647,6 +655,7 @@ async def on_inconsistent_state_event(self, msg: InconsistentStateEvent):
await self.file_unsubscribe()
await self.load_seed_notebook()
await self.send_file_subscribe()
self.inconsistent_state_event_count += 1

async def _on_delta_recv(self, msg: NewDeltaEvent):
"""
Expand Down