-
Notifications
You must be signed in to change notification settings - Fork 10
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
Records need lock protection #35
Comments
This sounds interesting. Does this refer to pages or articles or both? How about this:
But what for the UI? We could allow users to edit even if a file is locked and instead save his changes as a draft, but this then brings merging into the mix; the alternative is to simply don't allow editing of a locked file. Which is preferable? |
Ideally I'd like to make this a generic as possible so we can "lock" any record. I think this could have uses outside of Community so I'd like to keep the code as "gemifiable" as possible 😉 I think we want to block a user from accessing the record entirely if it is being edited by someone else. So in that case:
@sandal any thoughts about this process? |
@jordanbyron: Sounds right. One important feature: admins should be able to remove a lock. I.e they'd get displayed the same warning / error but have a link to click which would clear the lock. This is to prevent a record from being locked indefinitely and requiring an irb session to fix it. Alternatively, we could put a reasonable time limit on locking, but that seems more complicated. |
So this goes into a module then, a la
Oh right, |
And when the user that had the lock tries to save after it having been removed, he is redirected to the corresponding |
@jordanbyron Can it be the other way around? I could start with this and move on to #57 if it's still available; if someone beats me to it, I would of course continue to help with anything that's needed, since I had already said I'd work on that. Can we do that? |
Sure I just didn't want to tie up two tickets at the same time. I'll assign this one to you and you can resume #57 once you are done here. |
@ptn, I think the user should be kept on the edit page so that they have an opportunity to copy their contents, but I'm not sure whether that's essential. @jordanbyron can make the call. |
@sandal good call. So if an administrator "revokes" the lock bit, and the original user goes to update that record, they should be sent back to the edit page with their changes intact. Just like what happens when an validation error occurs. In fact, you'll probably want to use the ActiveRecord validations to handle this case. Then we don't have to do anything fancy. |
@jordanbyron @ptn I hate to bring this up at this late date, esp since the plugin looks so interesting and useful, but did you consider using postgresql's built-in locking mechanisms? Never done it myself, but just happened to look it up and what they call "advisory locks" seem kind of like just what is needed.
OTOH, might be messy to write the wrap the raw SQL for this, plus it wouldn't be usable outside of postgresql databases. Interesting to know it exists though. |
@ericgj I didn't know that existed either. Like you said, this wouldn't be usable outside of postgres, and the fact that we are plucking this code out into a proper gem kills the usefulness of database-specific features - we are postgres only, but client code of the gem surely will not. Boo :-( |
Sadly I did not, but that looks very cool and right up our alley. Personally I don't mind if we lock the gem into a Postgres only feature. If it really is fast and works as well as the little abstract makes it out to, then I think it's worth looking into. @ptn would you mind playing around with the feature locally to see if it would work for us? |
Oh, if being postgres-only is not a problem, then let's play with it. I'll let you know what I can find. |
Guys, I'll need to postpone this until next week's Fixing Mendicant - Anything Goes, since I'll have more free time then. I'm sorry 😓 |
@ptn that's ok. It looks like I won't have much time before next week to help you with this patch anyway. Let me know when you've got some more free time to work on this. 👷 |
Just a quick message to revive this: I did some research this night and I think that we can use |
@ptn sounds good. Im going to close your first pull request so we can start from scratch with the new Postgres record locking approach. When you've made some progress send over a new request so I can check it out. Thanks again for reworking this 😄 |
Currently it's very easy for two users to overwrite each others changes without knowing in. We need some type of locking mechanism to prevent this from happening.
The text was updated successfully, but these errors were encountered: