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

Edits out of order in history of shared note #1816

Closed
tmchartrand opened this issue Jan 7, 2020 · 3 comments · Fixed by #2148
Closed

Edits out of order in history of shared note #1816

tmchartrand opened this issue Jan 7, 2020 · 3 comments · Fixed by #2148
Labels
bug Something isn't working

Comments

@tmchartrand
Copy link

Expected

Even on a shared note, edits from multiple users and clients should appear in order in the note history, and the Latest version shown by default should actually be the latest edit.

Observed

In both older version (electron app, maybe 1.4?) and web app, current version somehow reverted to older edit. On web version, that edit appears as the most recent in the history, out of order by date, followed by an edit with a more recent timestamp that appears identical to the old edit. In electron app, the old edit appears in the proper place in history, and the latest version shown is the identical new edit, with the true current version lost in between.

Reproduced

Not sure exactly how it got in this state and haven't yet managed to reproduce a simpler example.

  1. Note owner creates note (electron app, maybe 1.4?), Nov 30
  2. Collaborator makes large-scale edits (iphone app), Dec 28
  3. (speculated) note opened in electron app, change consisting of no actual edits to Nov 30 version is somehow pushed before note is synced?
  4. Both see note reverted to initial version, with odd note history.

(Optional) If applicable, add screenshots, animations, or videos to help illustrate your problem.

@tmchartrand tmchartrand added the bug Something isn't working label Jan 7, 2020
@dmsnell
Copy link
Member

dmsnell commented Jan 7, 2020

thanks for reporting @tmchartrand.

it sounds like something is fishy, but I want to make sure we separate quirks in the way syncing works from defects in the app.

the order of the edits in the revision slider should come in the order that the edits applied to the account. that is, you may find that even though you made edits on device A in the real world an hour before making other edits on device B, if device B was connected to the internet and send its changes before re-connecting device A to the internet, then the edits will look like they were swapped.

we still have a ways to go to better communicate what's happening, but the revision slider is showing the order in which the edits applied to the note and that may not match when they were physically entered.


that being said, I'm struggling to understand the sequence of events and outcomes as described. if it's truly the Electron app version 1.4 though I wouldn't be surprised if there's out-of-order listing - we did have a bug that was related to this very thing because we sorted the revisions by their listed date instead of the edit sequence.

it's all very confusing, but see if what I wrote about the ordering makes sense and then would you be willing to try and expand on what you saw? if you want to share screenshots then please contact our support where we can work through this individually and privately with you.

@tmchartrand
Copy link
Author

ok, that makes more sense for the ordering discrepancy from what you've said.
I'm still not sure whether this could be due just to an offline device syncing an old change very late. Looking back at the history, the edit that appears to have synced later than its marked date (in the current web version) is actually incorporated in subsequent edits (by date, which appear before it in the history timeline). It seems like somehow it was actually synced at the time, but wasn't marked as synced until the later date or something.

@dmsnell
Copy link
Member

dmsnell commented Jan 7, 2020

but wasn't marked as synced until the later date or something.

For technical reasons it's the Simplenote app that records the edit date and there's no timestamp ever given for "this is when the change was sync'd."

Note too that if a device tries to sync its content and discovers that the edit cannot apply cleanly (for example, on device A cat was changed to bat while on device B cat was changed to rat) then it will tell the server to adopt its changes as the new real copy of the note.

In these cases you'll find a revision for the old content right behind the edit. This is to prevent such a conflicting edit from causing you to lose your data.

dmsnell added a commit that referenced this issue Sep 21, 2020
co-authored by @belcherj and @codebykat with design work by @SylvesterWilmott 

## Description

We've been unable to resolve the worst sync bugs in the application and feature development has been artificially limited by the fact that we have to fight a number of data-flow issues tightly coupling different levels of the application's architecture together.

In this branch, we're ripping apart the entire app state and Simperium data flow to rebuild it in order to remove a number of those couplings and races. This commit changes most of the app and was rolled out in staging to test the changes.

We're also replacing `draft-js` with `Monaco` which is almost as big of a change conceptually as changing the state. Moving to `Monaco` allows us to remove a copy of the note data from the app and allows us to maintain a fully-synchronous update cycle, eliminating a race condition between the Simperium copy of the data, the app copy, and the contents in the text buffer.

## Major code changes

 - The interface between `node-simperium` and this app has been moved into Redux state and out of `indexedDB`. The `indexedDB` interface as asynchronous and led to sync issues under a variety of race conditions with the network data, remote updates, browser tab scheduling, whether the browser was focused or hidden behind other windows, and more. The new synchronous interface guarantees that updates occur when we expect them to occur and therefore will be updated by the time we continue processing changes and updates from the server.
 - `Monaco`'s synchronous plaintext interface allows us to extend the atomic "all updates occur together and instantaneously" paradigm to the text buffer. By sharing the note data in the text editor, in the app, and in `node-simperium`, we will guarantee that we won't accidentally apply new edits to old data.
 - In many cases we have been dispatching multiple actions in order to perform one real action. For example, edit a note and then clear out the search state. Because these presented intermediate states for the app, partial updates, they have been removed. Now we have created new Redux actions for these real actions and app state has been adjusted so that each kind of data has its own reducer and those reducers listen to all the actions which could affect them.  Now we will see a single dispatch that multiple reducers listen to instead of dispatching one action type for each reducer.
 - The Simperium connection has been moved into a new centralized middleware. All Simperium interactions take place in this middleware and are no longer woven into the app. This allows the app to update so that there's only ever one copy of a note's data and it's always up to date with the text editor. This resolves longstanding issues with the note list showing expired data. It also allows us to model the Simperium connection as a reactive system that responds to changes in the app and injects new events from the server in a way that's independent from local operation. This has dramatically simplified many different subsystems.
 - The persistence layer has now been created as a separate subsystem from before, when it was integrated with the Simperium code. It now operates as a kind of background worker that persists the Redux state into `indexedDB` and stores the entire contents atomically. Previously, integrated into the note bucket, the persistence layer would update each note, ghost, and bucket value separately leading to mismatches between a note and the base version it was built from, leading to sync issues.
 - So-called "prop drilling" has been replaced by connecting components in the React tree to state. This was done to simplify the interfaces around the app. It was previously difficult to understand what exactly was executing with the `onAction` props because there wasn't a clear way to walk up the component tree in an editor without resorting to text searching. Any `onEdit` type actions have been replaced with `dispatchProps` that directly dispatch the intended actions.

## Related or fixed issues

### Defects
Resolves #2171 (note display doesn't update height immediately upon change from menu bar)
Resolves #2074 (floating IME on Korean input)
Resolves #2014 (when opened note changes so it's not in the search, it still stays open)
Resolves #1953 (when renaming tag, update in search bar if tag opened)
Resolves #1942 (can't easily select start of note content)
Resolves #1887 (renaming a tag removes it from a note)

#### Cursor position and movement
Resolves #2085 (cursor jumps to new note)
Resolves #2035 (cursor hidden at bottom of note)
Resolves #1595 (restore cursor position when flipping between edit/preview mode)
Resolves #1477 (cursor jumping in Windows)

#### Synchronization
Resolves #1938 (not restoring tags when reverting to an earlier revision)
Resolves #1641 (updates to a tag in one session don't update in other sessions until they reload)
Resolves #1640 (infinite duplication of tag name when editing tag)
Resolves #1562 (content not syncing)
Resolves #1520 (only syncing one note at a time/per session)
Resolves #1291 (quirky unsynced changes info)
Resolves #502 (data loss when editing simultaneous with iOS)
Resolves #459 (show note sync indicator)

#### Force-sync
#1897
#800

#### Ghost-Writing
Resolves #2030
Resolves #1787

### Enhancements
Resolves #2162 (mostly - additional syncing metadata for notes)
Resolves #1836 (remove `app-state`)
Resolves #1816 (confusing revision history ordering)
#1537 (add indicator to show syncing status)
Resolves #2036 (logging-out in one sessions logs out all sessions)
Resolves #1410 (logout is buried in app settings and hard to find)

#### Private Mode
#1924 - functionality in Firefox private mode other than offline persistence

### Performance
Resolves #2172 (slow app)
Resolves #501 (slow loading large notes)

### Deprecations
Resolves #2117 (audit use of draftJS)
Resolves #1762 (decorator performance in draftJS)
Resolves #1026 (use of `token` in `localStorage` in `boot.js`)

### Possibly - check these
#1698 (problems with Korean input and lists at start of note)
#1619 (buggy Japanese IME conversion)
#1572 (RTL languages - checked tasks moving to the right)
#1511 (missing characters on Korean IME conversion)
#1456 (slow, possibly 4K-resolution-related)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants