This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
synapse/storage/schema/main/delta/80 Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ Fix a rare race that could block new events from being sent for up to two minutes. Introduced in v1.90.0.
Original file line number Diff line number Diff line change 1+ /* Copyright 2023 The Matrix.org Foundation C.I.C
2+ *
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+
16+ -- To avoid the possibility of a deadlock, lock the
17+ -- `worker_read_write_locks_mode` table so that we serialize inserts/deletes
18+ -- for a specific lock name/key.
19+
20+ CREATE OR REPLACE FUNCTION delete_read_write_lock_parent_before() RETURNS trigger AS $$
21+ BEGIN
22+ -- `PERFORM` is a `SELECT` which discards the rows.
23+ PERFORM * FROM worker_read_write_locks_mode
24+ WHERE
25+ lock_name = OLD.lock_name
26+ AND lock_key = OLD.lock_key
27+ FOR UPDATE;
28+
29+ RETURN OLD;
30+ END
31+ $$
32+ LANGUAGE plpgsql;
33+
34+ DROP TRIGGER IF EXISTS delete_read_write_lock_parent_before_trigger ON worker_read_write_locks;
35+ CREATE TRIGGER delete_read_write_lock_parent_before_trigger BEFORE DELETE ON worker_read_write_locks
36+ FOR EACH ROW
37+ EXECUTE PROCEDURE delete_read_write_lock_parent_before();
You can’t perform that action at this time.
0 commit comments