Skip to content

audit_events has composite primary key. Composite primary key is ignored.

Summary

We upgraded our Gitlab instance from 13.1.4 to 13.9.1 using the zero downtime update procedure. During the gitlab-rake db:migrate step of the upgrade, we encountered a fatal error. Our instance seems to have still upgraded successfully despite the database migration abort. We are however concerned that an unclean migration could cause issues in the future.

Steps to reproduce

Not sure if the issue is reproducible outside of our environment, but I can still generate the error on our 13.9.1 Gitlab instance by running gitlab-rake db:migrate again.

What is the current bug behavior?

Currently the database migration is aborted.

What is the expected correct behavior?

I would expect the database migration to not abort.

Relevant logs and/or screenshots

The following is the exact error produced when running gitlab-rake db:migrate.

== 20200722202318 BackfillPartitionedAuditEvents: migrating ===================
-- transaction_open?()
   -> 0.0000s
WARNING: Active Record does not support composite primary key.

audit_events has composite primary key. Composite primary key is ignored.
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

the column: argument must be set to a column name to use for ordering rows
/opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:52:in `each_batch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/background_migration_helpers.rb:105:in `queue_background_migration_jobs_by_range_at_intervals'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb:383:in `enqueue_background_migration'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb:108:in `enqueue_partitioning_data_migration'
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20200722202318_backfill_partitioned_audit_events.rb:13:in `up'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'

Caused by:
ArgumentError: the column: argument must be set to a column name to use for ordering rows
/opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:52:in `each_batch'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/migrations/background_migration_helpers.rb:105:in `queue_background_migration_jobs_by_range_at_intervals'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb:383:in `enqueue_background_migration'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb:108:in `enqueue_partitioning_data_migration'
/opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20200722202318_backfill_partitioned_audit_events.rb:13:in `up'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Results of GitLab environment info

Expand for output related to GitLab environment info

System information
System:         CentOS 7.4.1708
Current User:   git
Using RVM:      no
Ruby Version:   2.7.2p137
Gem Version:    3.1.4
Bundler Version:2.1.4
Rake Version:   13.0.3
Redis Version:  6.0.10
Git Version:    2.29.0
Sidekiq Version:5.2.9
Go Version:     unknown

GitLab information
Version:        13.9.1
Revision:       03979b4aaf0
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     11.10
URL:            https://myhostname
HTTP Clone URL: https://myhostname/some-group/some-project.git
SSH Clone URL:  git@myhostname:some-group/some-project.git
Using LDAP:     yes
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        13.16.1
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell
Git:            /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 13.16.1 ? ... OK (13.16.1) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 100 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 30/10 ... yes 30/11 ... yes 7/12 ... yes 31/15 ... yes 31/18 ... yes 17/21 ... yes 17/22 ... yes 20/24 ... yes 20/25 ... yes 20/26 ... yes 21/27 ... yes 20/28 ... yes 20/29 ... yes 21/30 ... yes 20/31 ... yes 20/32 ... yes 21/34 ... yes 20/35 ... yes 22/36 ... yes 31/52 ... yes 32/53 ... yes 32/54 ... yes 32/55 ... yes 32/56 ... yes 32/57 ... yes 31/60 ... yes 30/63 ... yes 3/64 ... yes 3/65 ... yes 3/66 ... yes 3/81 ... yes 27/82 ... yes 28/83 ... yes 38/84 ... yes 38/85 ... yes 23/86 ... yes 23/87 ... yes 27/88 ... yes 39/89 ... yes 39/90 ... yes 40/91 ... yes 40/92 ... yes 40/93 ... yes 41/94 ... yes 42/95 ... yes 42/96 ... yes 27/97 ... yes 43/98 ... yes 43/99 ... yes 43/100 ... yes 43/101 ... yes 48/102 ... yes 48/103 ... yes 48/104 ... yes 49/105 ... yes 49/106 ... yes 49/107 ... yes 49/108 ... yes 49/109 ... yes 49/110 ... yes 45/111 ... yes 46/112 ... yes 46/113 ... yes 47/114 ... yes 47/115 ... yes 47/116 ... yes 47/117 ... yes 45/118 ... yes 23/119 ... yes 44/120 ... yes 44/121 ... yes 44/122 ... yes 29/123 ... yes 29/124 ... yes 15/128 ... yes 145/129 ... yes 145/130 ... yes 145/131 ... yes 145/132 ... yes 145/133 ... yes 145/134 ... yes 145/135 ... yes 150/136 ... yes 56/191 ... yes 64/192 ... yes 7/193 ... yes 7/194 ... yes 60/195 ... yes 7/196 ... yes 61/197 ... yes 7/198 ... yes 7/199 ... yes 61/201 ... yes 61/202 ... yes 61/205 ... yes 62/206 ... yes 64/208 ... yes 7/210 ... yes 60/211 ... yes 56/212 ... yes 60/213 ... yes 60/214 ... yes 66/216 ... yes 66/217 ... yes 70/230 ... yes 70/231 ... yes 2/232 ... yes 64/233 ... yes 64/236 ... yes 15/240 ... yes 60/244 ... yes 161/245 ... yes 64/249 ... yes 20/255 ... yes 16/258 ... yes 29/259 ... yes 51/260 ... yes 62/262 ... yes 7/263 ... yes 29/265 ... yes 22/266 ... yes 20/267 ... yes 60/268 ... yes 37/269 ... yes 37/270 ... yes 37/271 ... yes 37/272 ... yes 37/273 ... yes 85/274 ... yes 37/275 ... yes 37/276 ... yes 37/277 ... yes 60/278 ... yes 82/365 ... yes 20/366 ... yes 7/367 ... yes 87/368 ... yes 87/369 ... yes 87/370 ... yes 87/371 ... yes 74/372 ... yes 29/373 ... yes 7/374 ... yes 75/375 ... yes 15/376 ... yes 88/377 ... yes 88/378 ... yes 78/379 ... yes 161/380 ... yes 7/381 ... yes 7/391 ... yes 86/394 ... yes 74/411 ... yes 150/418 ... yes 7/424 ... yes 22/431 ... yes 106/432 ... yes 106/433 ... yes 106/434 ... yes 95/435 ... yes 150/436 ... yes 118/438 ... yes 118/439 ... yes 118/440 ... yes 118/441 ... yes 118/445 ... yes 90/448 ... yes 90/449 ... yes 60/450 ... yes 113/469 ... yes 101/556 ... yes 20/581 ... yes 78/584 ... yes 102/995 ... yes 95/1051 ... yes 118/1052 ... yes 101/1053 ... yes 68/1054 ... yes 60/1114 ... yes 68/1128 ... yes 68/1129 ... yes 68/1130 ... yes 68/1131 ... yes 29/1132 ... yes 74/1134 ... yes 162/1135 ... yes 56/1136 ... yes 60/1169 ... yes 18/1228 ... yes 102/1229 ... yes 118/1231 ... yes 102/1232 ... yes 29/1233 ... yes 106/1235 ... yes 102/1236 ... yes 72/1237 ... yes 29/1238 ... yes 100/1239 ... yes 95/1240 ... yes 60/1241 ... yes 60/1242 ... yes 60/1243 ... yes 60/1244 ... yes 60/1245 ... yes 60/1246 ... yes 60/1247 ... yes 60/1248 ... yes 60/1249 ... yes 60/1250 ... yes 60/1251 ... yes 60/1252 ... yes 60/1253 ... yes 60/1254 ... yes 60/1255 ... yes 60/1256 ... yes 95/1259 ... yes 162/1260 ... yes 195/1261 ... yes 195/1262 ... yes 100/1263 ... yes 66/1265 ... yes 118/1267 ... yes 100/1269 ... yes 100/1270 ... yes 100/1271 ... yes 100/1272 ... yes 78/1273 ... yes 100/1274 ... yes 181/1276 ... yes 100/1279 ... yes 43/1280 ... yes 7/1281 ... yes 50/1283 ... yes 21/1285 ... yes 100/1286 ... yes 100/1287 ... yes 100/1288 ... yes 180/1289 ... yes 100/1290 ... yes 100/1291 ... yes 70/1292 ... yes 100/1293 ... yes 100/1295 ... yes 30/1296 ... yes 29/1297 ... yes 75/1298 ... yes 100/1299 ... yes 60/1300 ... yes 79/1302 ... yes 174/1303 ... yes 89/1304 ... yes 118/1305 ... yes 3/1306 ... yes 27/1307 ... yes 72/1309 ... yes 187/1310 ... yes 79/1313 ... yes 195/1315 ... yes 195/1316 ... yes 195/1317 ... yes 195/1318 ... yes 195/1319 ... yes 195/1320 ... yes 60/1323 ... yes 118/1324 ... yes 30/1325 ... yes 198/1326 ... yes 20/1327 ... yes 199/1329 ... yes 199/1330 ... yes 199/1331 ... yes 95/1334 ... yes 66/1336 ... yes 48/1338 ... yes 102/1339 ... yes 3/1341 ... yes 100/1344 ... yes 29/1345 ... yes 100/1346 ... yes 195/1347 ... yes 78/1349 ... yes 78/1350 ... yes 15/1351 ... yes 206/1352 ... yes 29/1353 ... yes 211/1354 ... yes 207/1355 ... yes 207/1356 ... yes 206/1357 ... yes 211/1358 ... yes 204/1359 ... yes 210/1361 ... yes 206/1362 ... yes 7/1363 ... yes 78/1364 ... yes 172/1365 ... yes 172/1366 ... yes 172/1367 ... yes 64/1368 ... yes 37/1369 ... yes 95/1370 ... yes 64/1371 ... yes 95/1372 ... yes 118/1373 ... yes 95/1374 ... yes 207/1375 ... yes 206/1376 ... yes 206/1377 ... yes 211/1378 ... yes 217/1379 ... yes 206/1380 ... yes 211/1382 ... yes 95/1383 ... yes 195/1384 ... yes 187/1385 ... yes 211/1386 ... yes 100/1387 ... yes 223/1388 ... yes 109/1389 ... yes 211/1390 ... yes 100/1391 ... yes 229/1392 ... yes 7/1393 ... yes 95/1395 ... yes 207/1396 ... yes 3/1397 ... yes 187/1398 ... yes 37/1399 ... yes 37/1400 ... yes 211/1401 ... yes 3/1402 ... yes 30/1403 ... yes 109/1404 ... yes 37/1405 ... yes 228/1406 ... yes 100/1407 ... yes 100/1408 ... yes 60/1409 ... yes 232/1410 ... yes 118/1411 ... yes 40/1412 ... yes 43/1413 ... yes 118/1414 ... yes 20/1415 ... yes 3/1416 ... yes 7/1417 ... yes 20/1418 ... yes 232/1419 ... yes 30/1420 ... yes 199/1421 ... yes 30/1422 ... yes 180/1423 ... yes 27/1424 ... yes 187/1425 ... yes 175/1426 ... yes 29/1427 ... yes 118/1428 ... yes 37/1429 ... yes 95/1430 ... yes 62/1431 ... yes 68/1432 ... yes 59/1434 ... yes 118/1435 ... yes 195/1436 ... yes 232/1437 ... yes 56/1438 ... yes 195/1439 ... yes 95/1440 ... yes 64/1441 ... yes 118/1442 ... yes 106/1443 ... yes 180/1444 ... yes 216/1445 ... yes 158/1446 ... yes 64/1447 ... yes 7/1448 ... yes 79/1449 ... yes 7/1450 ... yes 7/1451 ... yes 72/1452 ... yes 100/1453 ... yes 3/1454 ... yes 261/1455 ... yes 100/1456 ... yes 118/1457 ... yes 261/1458 ... yes 238/1459 ... yes 50/1460 ... yes 58/1461 ... yes 58/1462 ... yes 181/1463 ... yes 181/1464 ... yes 232/1465 ... yes 232/1466 ... yes 72/1467 ... yes 285/1468 ... yes 285/1469 ... yes 287/1470 ... yes 211/1471 ... yes 281/1472 ... yes 281/1473 ... yes 118/1474 ... yes 37/1475 ... yes 253/1476 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.2) Git version >= 2.29.0 ? ... yes (2.29.0) Git user has default SSH configuration? ... yes Active users: ... 171 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... no Try fixing it: Please migrate all projects to hashed storage as legacy storage is deprecated in 13.0 and support will be removed in 14.0. For more information see: doc/administration/repository_storage_types.md

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Related issues

It seems that #292909 (closed) is related to this issue. However, this issue is causing our database migration to abort, whereas #292909 (closed) seems to be more about simply suppressing the warning message.