forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7fbcee1
committed
Log when GetNewOidWithIndex() fails to find unused OID many times.
GetNewOidWithIndex() generates a new OID one by one until it findsone not in the relation. If there are very long runs of consecutiveexisting OIDs, GetNewOidWithIndex() needs to iterate many timesin the loop to find unused OID. Since TOAST table can have a largenumber of entries and there can be such long runs of OIDs, there isthe case where it takes so many iterations to find new OID not inTOAST table. Furthermore if all (i.e., 2^32) OIDs are already used,GetNewOidWithIndex() enters something like busy loop and repeatsthe iterations until at least one OID is marked as unused.There are some reported troubles caused by a large number ofiterations in GetNewOidWithIndex(). For example, when insertinga billion of records into the table, all the backends doing thatinsertion operation got hang with 100% CPU usage at some point.Previously there was no easy way to detect that GetNewOidWithIndex()failed to find unused OID many times. So, for example, gdb fullbacktrace of hanged backends needed to be taken, in order toinvestigate that trouble. This is inconvenient and may not beavailable in some production environments.To provide easy way for that, this commit makes GetNewOidWithIndex()log that it iterates more than GETNEWOID_LOG_THRESHOLD but havenot yet found OID unused in the relation. Also this commit makesit repeat logging with exponentially increasing intervals untilit iterates more than GETNEWOID_LOG_MAX_INTERVAL, and makes itfinally repeat logging every GETNEWOID_LOG_MAX_INTERVAL unlessan unused OID is found. Those macro variables are used not tofill up the server log with the similar messages.In the discusion at pgsql-hackers, there was another idea to reportthe lots of iterations in GetNewOidWithIndex() via wait event.But since GetNewOidWithIndex() traverses indexes to find unusedOID and which will do I/O, acquire locks, etc, which will overwritethe wait event and reset it to nothing once done. So that ideadoesn't work well, and we didn't adopt it.Author: Tomohiro HiramitsuReviewed-by: Tatsuhito Kasahara, Kyotaro Horiguchi, Tom Lane, Fujii MasaoDiscussion:https://postgr.es/m/16722-93043fb459a41073@postgresql.org1 parent99dd75f commit7fbcee1
1 file changed
+49
-0
lines changedLines changed: 49 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
50 | 57 |
| |
51 | 58 |
| |
52 | 59 |
| |
| |||
318 | 325 |
| |
319 | 326 |
| |
320 | 327 |
| |
| 328 | + | |
| 329 | + | |
321 | 330 |
| |
322 | 331 |
| |
323 | 332 |
| |
| |||
353 | 362 |
| |
354 | 363 |
| |
355 | 364 |
| |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
356 | 394 |
| |
357 | 395 |
| |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
358 | 407 |
| |
359 | 408 |
| |
360 | 409 |
| |
|
0 commit comments
Comments
(0)