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

Uses a distributed lock on git handler to avoid race condition #134

Open
mgaitan opened this issue Apr 1, 2017 · 2 comments
Open

Uses a distributed lock on git handler to avoid race condition #134

mgaitan opened this issue Apr 1, 2017 · 2 comments

Comments

@mgaitan
Copy link
Owner

mgaitan commented Apr 1, 2017

a concurrent edition in a page can leave the repo in a dirty state like the following:

facundo@web:/home/www-pyar/pyarweb/pyarweb/waliki_data$ git status
HEAD detached from cd73ae5
Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:   PyCamp/OrganizandoUnPyCamp.rst

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   mi.rst

no changes added to commit (use "git add" and/or "git commit -a")

Explanation

the simplistic apprach of waliki uses system calls to the "git command". this process imply few commands (branch, commit, merge). If a second edition (on any page) is saved before a previous one finish, those git commands could be mixed

solution

we need to lock, at least the "Git.commit" method. Research the proper lib to use https://pypi.python.org/pypi?%3Aaction=search&term=distributed+lock&submit=search

@mgaitan
Copy link
Owner Author

mgaitan commented Apr 1, 2017

this seems to be simple enough https://pypi.python.org/pypi/pylock/0.3

@wagnerflo
Copy link
Contributor

From my reading of pylock's documentation this package seems a bad choice. Anyone deploying a Waliki based website will then have to decide between:

  1. Increased effort for installing and maintaining either Redis or Memcache.
  2. Selecting the "Open (non-locking) backend" and gaining no improvement while still inheriting the increased complexity in Waliki code as well as more dependencies.

A distributed locking library that has a "fallback" to file locks for simple and small installations would be very much preferable IMO.

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

No branches or pull requests

2 participants