如何最好地处理多对多并发冲突?

发布于 2024-12-24 17:07:19 字数 545 浏览 1 评论 0原文

我们有一个类似于 Gmail 标签的应用程序功能 - 您可以“标记”项目。现在,这是一个并发应用程序,即,这个所谓的“白板”可由多个用户编辑 - 这意味着许多用户可以选择重新/分组项目。基本上可以同时标记多个项目。

肯定会有冲突,但问题是如何最好地处理?我想到的唯一策略类似于著名的 ALOHA 协议,即在提交之前检查是否有任何更改 - 如果是,则中止并通知用户;否则提交。在我看来,这是相当低效的。

这里有两个类似的想法 - 相比之下,一个困难,另一个更容易:

第一个更容易:) - 覆盖更改,即,重复项将被更新,但新的也会被标记。

困难之一:检查哪些内容将被“删除”,即,可能有一些不属于该分类(由用户 2 说)。即,用户 1 进行了更改,而用户 2 也同时进行了更改。基本上找到一组标记项目{user1 - user2})。恕我直言,这将非常困难,而且真的不值得付出努力。

我想知道在这种情况下使用的最佳实践解决方案是什么,既不会妨碍用户体验,也不会让他们感到困惑。

(这是一个带有 MySQL 后端和 Jquery/ajax 前端的 J2EE/Restlet 应用程序)

We have an application feature similar to gmail's labels - you can 'tag' the items. Now this is a concurrent application i.e., this so called 'whiteboard' is editable by multiple users - which means that many users can choose to re/group the items. Basically tag multiple items at the same time.

There will definitely be conflicts but the question is how best to handle it? The only strategy that comes to mind is similar to the famous ALOHA protocol i.e., check before commit if any thing has changed - if so, abort and inform user; else commit. This is quite inefficient IMO.

Here are two similar ideas - one difficult and the other easier by comparison:

Easier one first :) - overwrite changes i.e., the duplicates would just be updated but new ones would be tagged too.

Difficult one: Check for which are to be 'removed' i.e., there could be some that doesn't belong to the categorization (by user 2 say. i.e., user 1 made a change and user 2 also made it at the same time. Basically finding the set of tagged items {user1 - user2}). This is going to be extremely hard and really not worth the effort IMHO.

I was wondering what's the best practice solution to use in such a case which doesn't hinder the user experience and doesn't confuse them either.

(This is a J2EE/Restlet app with a MySQL backend and a Jquery/ajax front end)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怪异←思 2024-12-31 17:07:20

这个问题的答案实际上取决于您的用户是谁以及他们的期望。如果是我,我想我会期望在我完成之前收到用户创建更改的通知(stackoverflow 就是这样做的),并允许我无论如何提交更改或回滚。您提出的所有解决方案似乎都是可以接受的..这完全取决于您想要做什么。如果您询问如何使用 code 执行此操作,则必须先发布一些代码,以便我们可以看到您正在处理的内容。

另一种可能的解决方案与 #2 类似(只需在发生更改时覆盖更改),但保留每个更改的修订版本,以便轻松恢复,并且可以轻松判断更改是否是在其他更改之上进行的。

The answer to this question really depends on who your users are and what they expect. If it were me, I think I would anticipate being informed of a user creating changes before mine are done (stackoverflow does this), and allow me to commit changes anyway or roll back. All of the solutions you've presented seem acceptable .. it depends purely on what you want to do. If you're asking for how to do this with code, you are going to have to post some code first so we can see what you are dealing with.

Another possible solution would be similar to #2 (just overwrite changes as they occur), but keep a revision of each change to allow for easy reversions, and to make it easy to tell if changes were made on top of others.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文