Commit Graph

7 Commits

Author SHA1 Message Date
Stan Hu 0f5b735685 Fix stage index migration failing in PostgreSQL 10
As discussed in
https://www.postgresql.org/message-id/9922.1353433645%40sss.pgh.pa.us,
the PostgreSQL window function last_value may not consider the
right rows:

Note that first_value, last_value, and nth_value consider only the rows
within the "window frame", which by default contains the rows from the
start of the partition through the last peer of the current row. This is
likely to give unhelpful results for last_value and sometimes also
nth_value. You can redefine the frame by adding a suitable frame
specification (RANGE or ROWS) to the OVER clause. See Section 4.2.8 for
more information about frame specifications.

This query could be fixed by adding `RANGE BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING`, but that's quite verbose. It's simpler just to
use the first_value function.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59985
2019-04-03 22:47:51 -07:00
Grzegorz Bizon 0fd0b64be6 Use stages position column to track stage index 2018-05-01 14:30:44 +02:00
Grzegorz Bizon c9dc51111d Rename stage index column name to priority column 2018-04-24 15:48:10 +02:00
Grzegorz Bizon d7e8bfac48 Improve stages index migration code readability 2018-04-24 14:15:26 +02:00
Grzegorz Bizon 657b24b7a5 Improve performance of stages index migration on PostgreSQL 2018-04-24 11:50:57 +02:00
Grzegorz Bizon 181d8f687d Make stages index background migration more idempotent 2018-04-24 11:07:37 +02:00
Grzegorz Bizon 02999234d4 Add background migration that migrates stages indices 2018-04-24 11:07:37 +02:00