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
ブログ記事noが重複して保存されるケースがある #1596
Comments
トランザクションでは、save() は普通に使えます。 |
@ryuring ありがとうございます!!トライしてきます |
@materializing これ、先日権藤さんと話してたんですが、トランザクションだけでは、参照と更新の両方をロックすることはできないかもしれません。 |
トランザクションだけでは難しいって @materializing と @seto1 から聞いた話なんです。 |
ryuring
added a commit
to ryuring/basercms
that referenced
this issue
Jan 14, 2021
ryuring
added a commit
that referenced
this issue
Jan 20, 2021
ryuring
pushed a commit
that referenced
this issue
Apr 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
概要
・ブログ記事URLに利用されるno値が重複することがある
→ 2ユーザー同時保存で、重複が再現されることを確認
なので、noの割り振り処理に重複が発生しないようにして解消したい、です。
これまで調査・確認してきたこと
LOCK TABLES mysite_blog_posts write, mysite_blog_posts AS BlogPost write;
ALTER TABLE mysite_blog_posts ADD UNIQUE blog_content_id_no (blog_content_id, no);
検討事項の案
INSERT INTO mysite_blog_posts (no) (SELECT MAX(no) + 1 FROM mysite_blog_posts)
アイデアで出たもの
最終noの値を持った行だけをロックすること。試してみたのは以下の内容。
NOは重複しなくなりましたが、使ったことがなく深く理解ある状態ではないので、
例えば InnoDB以外では動かない、とかの副作用が考えられる内容です。
また、他のDBどうすると良いんだろう?とかいろいろあるとは思うので、
まずはMySQL+InnoDBの組み合わせ時の対応に絞って考える、でも良いと思うのでなんとかしたいのであります。
すみませんが、何卒baserCMS プロジェクト開発メンバーみなさんのご協力を得たいです!
baserCMS version : 4.4.2以下
The text was updated successfully, but these errors were encountered: