Skip to content

disconnect client if it submits an already accepted changeset based on a...#2091

Merged
JohnMcLear merged 1 commit intoether:developfrom
webzwo0i:disconnect-if-an-old-cs-is-submitted-twice
Dec 29, 2014
Merged

disconnect client if it submits an already accepted changeset based on a...#2091
JohnMcLear merged 1 commit intoether:developfrom
webzwo0i:disconnect-if-an-old-cs-is-submitted-twice

Conversation

@webzwo0i
Copy link
Copy Markdown
Member

...n old revision

a changeset that is based on an old revision and contains the same changes that have produced baseRev+1 will satisfy the Changeset.follow checks and a new revision is pushed to all clients, but won't contain any real changes (e.g. if a cs that deletes all default text is submitted twice with baseRev:0, "Z:6c<6b|5-6b$", a new revision 2 that contains "Z:1>0$" will be pushed).
there is no limit how old a baseRev can be compared to the current head revision - which is good, because there cannot be a good approximation for this, as it depends on the number of clients, the size of the pad etc.
but it is bad in the described case as it can be used to insert an endless amount of revisions and the consequence are endless db round trips.

I left a "TODO" notice in the patch, because as I understand it, the client should stop sending changesets, receive all revisions and update its view of the pad to the latest head, and check if the changeset is still okay and resubmit it. but I couldn't find code that somehow does this, so I don't know what really happens, in case the client has missed some NEW_CHANGES.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, you can conveniently just throw the error here, and have the catch block do the work for you... DRYs things up ;)

@marcelklehr
Copy link
Copy Markdown
Contributor

I think disconnecting is a very drastic measure, since it could happen pretty often that two users delete the same character concurrently..

I don't think there is currently any code that deals with updating the client with missed changes. I think this is probably a good way of fixing this behavior.

@JohnMcLear
Copy link
Copy Markdown
Member

@marcelklehr did you want to see this in 1.4?

@marcelklehr
Copy link
Copy Markdown
Contributor

Nah, I think we should deal with this properly. My concern is, that a client with high latency might send the same cs a second time after some timeout. With this fix in place it would get disconnected.

@JohnMcLear
Copy link
Copy Markdown
Member

@webzwo0i did you want to submit a fix that doesn't disconnect the user?

@webzwo0i
Copy link
Copy Markdown
Member Author

yes, please give me some days to test

@webzwo0i
Copy link
Copy Markdown
Member Author

webzwo0i commented Dec 4, 2014

webzwo0i@fd66cfd

@JohnMcLear
Copy link
Copy Markdown
Member

@marcelklehr are you happy with this? :)

@webzwo0i
Copy link
Copy Markdown
Member Author

webzwo0i commented Dec 4, 2014

in case two clients edit concurrently and submit the same cs, the first client gets ACCEPT_COMMIT and the second gets NEW_CHANGES.
no one is disconnected anymore, however i need to test if the second client has a problem updating its state to the latest head revision - only node-side so far

@marcelklehr
Copy link
Copy Markdown
Contributor

The question is indeed, what will the client do? I think it will try to resend its changes after rebasing them against new changes. Looks good to me, if your test succeeds then it's good to merge, imo.

JohnMcLear added a commit that referenced this pull request Dec 29, 2014
…mitted-twice

disconnect client if it submits an already accepted changeset based on a...
@JohnMcLear JohnMcLear merged commit 3fe8020 into ether:develop Dec 29, 2014
@webzwo0i webzwo0i deleted the disconnect-if-an-old-cs-is-submitted-twice branch April 18, 2015 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants