Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can I do to prevent write-write conflicts on a wiki-style website?

Tags:

wiki

usability

On a wiki-style website, what can I do to prevent or mitigate write-write conflicts while still allowing the site to run quickly and keeping the site easy to use?

The problem I foresee is this:

  1. User A begins editing a file
  2. User B begins editing the file
  3. User A finishes editing the file
  4. User B finishes editing the file, accidentally overwriting all of User A's edits

Here were some approaches I came up with:

  • Have some sort of check-out / check-in / locking system (although I don't know how to prevent people from keeping a file checked out "too long", and I don't want users to be frustrated by not being allowed to make an edit)
  • Have some sort of diff system that shows an other changes made when a user commits their changes and allows some sort of merge (but I'm worried this will hard to create and would make the site "too hard" to use)
  • Notify users of concurrent edits while they are making their changes (some sort of AJAX?)

Any other ways to go at this? Any examples of sites that implement this well?

like image 576
Daniel LeCheminant Avatar asked Mar 08 '09 19:03

Daniel LeCheminant


5 Answers

Remember the version number (or ID) of the last change. Then read the entry before writing it and compare if this version is still the same.

In case of a conflict inform the user who was trying to write the entry which was changed in the meantime. Support him with a diff.

Most wikis do it this way. MediaWiki, Usemod, etc.

like image 151
stesch Avatar answered Nov 12 '22 01:11

stesch


Three-way merging: The first thing to point out is that most concurrent edits, particularly on longer documents, are to different sections of the text. As a result, by noting which revision Users A and B acquired, we can do a three-way merge, as detailed by Bill Ritcher of Guiffy Software. A three-way merge can identify where the edits have been made from the original, and unless they clash it can silently merge both edits into a new article. Ideally, at this point carry out the merge and show User B the new document so that she can choose to further revise it.

Collision resolution: This leaves you with the scenario when both editors have edited the same section. In this case, merge everything else and offer the text of the three versions to User B - that is, include the original - with either User A's version in the textbox or User B's. That choice depends on whether you think the default should be to accept the latest (the user just clicks Save to retain their version) or force the editor to edit twice to get their changes in (they have to re-apply their changes to editor A's version of the section).

Using three-way merging like this avoids lock-outs, which are very difficult to handle well on the web (how long do you let them have the lock?), and the aggravating 'you might want to look again' scenario, which only works well for forum-style responses. It also retains the post-respond style of the web.

If you want to Ajax it up a bit, dynamically 3-way merge User A's version into User B's version while they are editing it, and notify them. Now that would be impressive.

like image 25
Phil H Avatar answered Nov 12 '22 01:11

Phil H


In Mediawiki, the server accepts the first change, and then when the second edit is saved a conflicts page comes up, and then the second person merges the two changes together. See Wikipedia: Help:Edit Conflicts

like image 27
Adrian Archer Avatar answered Nov 12 '22 01:11

Adrian Archer


Using a locking mechanism will probably be the easiest to implement. Each article could have a lock field associated with it and a lock time. If the lock time exceeded some set value you'd consider the lock to be invalid and remove it when checking out the article for edit. You could also keep track of open locks and remove them on session close. You'd also need to implement some concurrency control in the database (autogenerated timestamps, perhaps) so that you could make sure that you are checking in an update to the version that you checked out, just in case two people were able to edit the article at the same time. Only the one with the correct version would be able successfully check in an edit.

You might also be able to find a difference engine that you could just use to construct differences, though displaying them in a wiki editor may be problematic -- actually displaying the differences is probably harder than constructing the diff. You'd rely on the versioning system to detect when you needed to reject an edit and perform a diff.

like image 1
tvanfosson Avatar answered Nov 12 '22 00:11

tvanfosson


In Gmail, if we are writing a reply to a mail and someone else sends a reply while we are still typing it, a popup appears indicating that there is a new update and the update itself appears as another post without a page reload. This approach would suit your needs and if you can use Ajax to show the exact post with a link to diff of what was just updated while User B is still busy typing his entry that would be great.

like image 1
Ravi Chhabra Avatar answered Nov 12 '22 01:11

Ravi Chhabra