|
1 | 1 | # Upgrading Yii PostgreSQL PDO Mutex |
2 | 2 |
|
3 | | -## Full-width advisory lock keys |
| 3 | +This file contains the upgrade notes. These notes highlight changes that could break your |
| 4 | +application when you upgrade the package from one version to another. |
4 | 5 |
|
5 | | -`PgsqlMutex` now derives two signed 32-bit PostgreSQL advisory-lock keys from the first eight bytes of the SHA-1 |
6 | | -hash of the mutex name. Previously it used two unsigned 16-bit keys from the first four bytes. The larger |
7 | | -64-bit keyspace reduces accidental contention between unrelated mutex names; hash collisions are still possible. |
| 6 | +> **Important!** The following upgrading instructions are cumulative. That is, if you want |
| 7 | +> to upgrade from version A to version C and there is version B between A and C, you need |
| 8 | +> to following the instructions for both A and B. |
8 | 9 |
|
9 | | -This changes the PostgreSQL keys for existing mutex names. Workers using the old and new mappings do not |
10 | | -coordinate: they can hold different advisory locks for the same mutex name at the same time. |
| 10 | +## Upgrade from 1.1 to 1.1.1 |
11 | 11 |
|
12 | | -Before starting any workers with the new mapping, stop or drain **all** workers using the old mapping that |
13 | | -coordinate through these mutexes, and let them finish their protected operations and release their locks. |
14 | | -Include web processes, queue workers, scheduled jobs and other applications sharing the locks. Restart them |
15 | | -with the same mapping. Do not overlap old and new workers during a rolling deployment. Apply the same |
16 | | -coordinated transition when rolling back. |
| 12 | +1.1.1 is under development; the version number is taken from [CHANGELOG.md](CHANGELOG.md). |
17 | 13 |
|
18 | | -The public API is unchanged. No persistent database data needs migrating; the change affects session-level locks. |
| 14 | +### Full-width advisory lock keys |
| 15 | + |
| 16 | +`PgsqlMutex` now derives two signed 32-bit PostgreSQL advisory-lock keys from the first eight |
| 17 | +bytes of the SHA-1 hash of the mutex name, instead of two unsigned 16-bit keys from the first |
| 18 | +four bytes. The larger 64-bit keyspace reduces accidental contention between unrelated mutex |
| 19 | +names; hash collisions are still possible. |
| 20 | + |
| 21 | +The public API is unchanged. No persistent database data needs migrating; the change affects |
| 22 | +session-level advisory locks. |
| 23 | + |
| 24 | +#### Required coordinated transition |
| 25 | + |
| 26 | +The PostgreSQL keys for existing mutex names change. Old and new mappings do not coordinate: |
| 27 | +workers on the old mapping and workers on the new mapping can hold **different** advisory locks |
| 28 | +for the same mutex name at the same time, so exclusion for the same name is broken while both |
| 29 | +mappings run. |
| 30 | + |
| 31 | +Before starting any process with the new mapping, stop or drain **all** old-mapping processes |
| 32 | +that coordinate through these mutexes and let them finish their protected operations and release |
| 33 | +their locks. This includes web processes, queue workers, scheduled jobs and other applications |
| 34 | +sharing the same locks. Do not overlap old and new mappings during a rolling deployment. |
| 35 | + |
| 36 | +When rolling back to the old mapping, apply the same transition in reverse: stop or drain all |
| 37 | +new-mapping processes first, then start the old ones. Never run old and new mappings together |
| 38 | +while same-name exclusion is required. |
0 commit comments