Commit 89aa2a6b authored by Vincent Pelletier's avatar Vincent Pelletier

Products.CMFActivity.Activity.SQLBase: Drop "FOR UPDATE".

This SELECT option was added when the UPDATE query was split into a
SELECT + UPDATE query pair, in order to try to avoid deadlocks in mariadb.
  commit 7daaf0a5
  Author: Vincent Pelletier <vincent@nexedi.com>
  Date:   Fri Jun 7 16:53:11 2013 +0200

      Work around poor UPDATE use of index.
That was not completely successful, and another attempt was since made,
which further ipmproved the situation:
  commit e21aa47f601a98f767e2d3e8490b20b7f409933c
  Author: Vincent Pelletier <vincent@nexedi.com>
  Date:   Fri Sep 17 11:34:46 2021 +0900

      CMFActivity.Activity.SQLBase: Reduce the number of deadlocks

This change made the "FOR UPDATE" option obsolete: there should be
virtually no parallelism between the SELECT and UPDATE queries.
By which I mean only 3rd-party accesses (like an admin on a mysql console)
would bypass the SQL lock, causing index-update-level locking issues.

Checking now, I see that removing "FOR UPDATE" on the "node>0" query makes
that query (with LIMIT 30) run about 5 times faster:
With FOR UPDATE:    0.509s
Without FOR UPDATE: 0.090s
This difference is enough to cause significant activity starvation on a
63-processing-nodes cluster where such activities run in about 1s, just
because of the amount of contention on the SQL lock, itself because of the
duration of every execution of this query.

So remove this now-redundant option.

It is expected that this will improve activity processing performance in
general, beyond just the starvation issue which led to this discovery.
parent 34f4ae37
Pipeline #23519 failed with stage
...@@ -775,8 +775,7 @@ CREATE TABLE %s ( ...@@ -775,8 +775,7 @@ CREATE TABLE %s (
b" processing_node=0 AND" b" processing_node=0 AND"
b" %s%s" b" %s%s"
b" ORDER BY priority, date" b" ORDER BY priority, date"
b" LIMIT %i" b" LIMIT %i" % args,
b" FOR UPDATE" % args,
0, 0,
)) ))
else: else:
...@@ -789,7 +788,6 @@ CREATE TABLE %s ( ...@@ -789,7 +788,6 @@ CREATE TABLE %s (
b" %s%s" b" %s%s"
b" ORDER BY priority, date" b" ORDER BY priority, date"
b" LIMIT %i" b" LIMIT %i"
b" FOR UPDATE"
b")" % args).format b")" % args).format
result = Results(query( result = Results(query(
b"SELECT *" b"SELECT *"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment