forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit171c457
committed
Fix and simplify some usages of TimestampDifference().
Introduce TimestampDifferenceMilliseconds() to simplify callersthat would rather have the difference in milliseconds, instead ofthe select()-oriented seconds-and-microseconds format. This getsrid of at least one integer division per call, and it eliminatessome apparently-easy-to-mess-up arithmetic.Two of these call sites were in fact wrong:* pg_prewarm's autoprewarm_main() forgot to multiply the secondsby 1000, thus ending up with a delay 1000X shorter than intended.That doesn't quite make it a busy-wait, but close.* postgres_fdw's pgfdw_get_cleanup_result() thought it needed to computemicroseconds not milliseconds, thus ending up with a delay 1000X longerthan intended. Somebody along the way had noticed this problem butmisdiagnosed the cause, and imposed an ad-hoc 60-second limit ratherthan fixing the units. This was relatively harmless in context, becausewe don't care that much about exactly how long this delay is; still,it's wrong.There are a few more callers of TimestampDifference() that don'thave a direct need for seconds-and-microseconds, but can't useTimestampDifferenceMilliseconds() either because they do needmicrosecond precision or because they might possibly deal withintervals long enough to overflow 32-bit milliseconds. It might beworth inventing another API to improve that, but that seems outsidethe scope of this patch; so those callers are untouched here.Given the fact that we are fixing some bugs, and the likelihoodthat future patches might want to back-patch code that uses thisnew API, back-patch to all supported branches.Alexey Kondratov and Tom LaneDiscussion:https://postgr.es/m/3b1c053a21c07c1ed5e00be3b2b855ef@postgrespro.ru1 parent1393acb commit171c457
File tree
7 files changed
+81
-97
lines changed- contrib
- pg_prewarm
- postgres_fdw
- src
- backend
- access/transam
- replication
- utils/adt
- include/utils
7 files changed
+81
-97
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 227 | + | |
| 228 | + | |
231 | 229 | | |
232 | 230 | | |
233 | 231 | | |
234 | 232 | | |
235 | 233 | | |
236 | | - | |
237 | | - | |
238 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
239 | 237 | | |
240 | 238 | | |
241 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1140 | 1140 | | |
1141 | 1141 | | |
1142 | 1142 | | |
1143 | | - | |
1144 | | - | |
1145 | 1143 | | |
1146 | 1144 | | |
1147 | 1145 | | |
1148 | | - | |
| 1146 | + | |
| 1147 | + | |
1149 | 1148 | | |
1150 | 1149 | | |
1151 | 1150 | | |
1152 | 1151 | | |
1153 | | - | |
1154 | | - | |
1155 | | - | |
1156 | | - | |
1157 | 1152 | | |
1158 | 1153 | | |
1159 | 1154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6005 | 6005 | | |
6006 | 6006 | | |
6007 | 6007 | | |
6008 | | - | |
6009 | | - | |
| 6008 | + | |
6010 | 6009 | | |
6011 | 6010 | | |
6012 | 6011 | | |
| |||
6047 | 6046 | | |
6048 | 6047 | | |
6049 | 6048 | | |
6050 | | - | |
6051 | | - | |
6052 | | - | |
| 6049 | + | |
| 6050 | + | |
| 6051 | + | |
6053 | 6052 | | |
6054 | 6053 | | |
6055 | 6054 | | |
| |||
6066 | 6065 | | |
6067 | 6066 | | |
6068 | 6067 | | |
6069 | | - | |
6070 | | - | |
| 6068 | + | |
| 6069 | + | |
6071 | 6070 | | |
6072 | | - | |
6073 | | - | |
| 6071 | + | |
6074 | 6072 | | |
6075 | 6073 | | |
6076 | | - | |
6077 | | - | |
| 6074 | + | |
6078 | 6075 | | |
6079 | 6076 | | |
6080 | 6077 | | |
6081 | | - | |
| 6078 | + | |
6082 | 6079 | | |
6083 | 6080 | | |
6084 | 6081 | | |
| |||
8448 | 8445 | | |
8449 | 8446 | | |
8450 | 8447 | | |
8451 | | - | |
8452 | | - | |
8453 | | - | |
8454 | | - | |
8455 | | - | |
8456 | | - | |
8457 | | - | |
8458 | | - | |
8459 | | - | |
8460 | | - | |
| 8448 | + | |
| 8449 | + | |
| 8450 | + | |
| 8451 | + | |
| 8452 | + | |
8461 | 8453 | | |
8462 | 8454 | | |
8463 | 8455 | | |
8464 | 8456 | | |
8465 | | - | |
8466 | | - | |
8467 | | - | |
| 8457 | + | |
| 8458 | + | |
8468 | 8459 | | |
8469 | | - | |
8470 | | - | |
8471 | | - | |
| 8460 | + | |
| 8461 | + | |
8472 | 8462 | | |
8473 | 8463 | | |
8474 | | - | |
8475 | | - | |
8476 | | - | |
8477 | | - | |
| 8464 | + | |
| 8465 | + | |
8478 | 8466 | | |
8479 | 8467 | | |
8480 | 8468 | | |
| |||
8483 | 8471 | | |
8484 | 8472 | | |
8485 | 8473 | | |
8486 | | - | |
8487 | | - | |
8488 | | - | |
| 8474 | + | |
| 8475 | + | |
8489 | 8476 | | |
8490 | 8477 | | |
8491 | 8478 | | |
8492 | | - | |
8493 | | - | |
| 8479 | + | |
8494 | 8480 | | |
8495 | | - | |
8496 | | - | |
8497 | | - | |
| 8481 | + | |
8498 | 8482 | | |
8499 | 8483 | | |
8500 | 8484 | | |
8501 | 8485 | | |
8502 | 8486 | | |
8503 | | - | |
8504 | | - | |
| 8487 | + | |
8505 | 8488 | | |
8506 | 8489 | | |
8507 | 8490 | | |
| |||
8514 | 8497 | | |
8515 | 8498 | | |
8516 | 8499 | | |
8517 | | - | |
8518 | | - | |
8519 | | - | |
| 8500 | + | |
| 8501 | + | |
| 8502 | + | |
8520 | 8503 | | |
8521 | | - | |
8522 | | - | |
| 8504 | + | |
| 8505 | + | |
8523 | 8506 | | |
8524 | 8507 | | |
8525 | 8508 | | |
| |||
12024 | 12007 | | |
12025 | 12008 | | |
12026 | 12009 | | |
12027 | | - | |
12028 | | - | |
12029 | | - | |
| 12010 | + | |
12030 | 12011 | | |
12031 | | - | |
12032 | 12012 | | |
12033 | | - | |
| 12013 | + | |
12034 | 12014 | | |
12035 | 12015 | | |
12036 | 12016 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | 323 | | |
328 | 324 | | |
329 | 325 | | |
| |||
340 | 336 | | |
341 | 337 | | |
342 | 338 | | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
| 339 | + | |
| 340 | + | |
348 | 341 | | |
349 | 342 | | |
350 | 343 | | |
| |||
355 | 348 | | |
356 | 349 | | |
357 | 350 | | |
358 | | - | |
359 | 351 | | |
360 | 352 | | |
361 | 353 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | 354 | | |
367 | 355 | | |
368 | 356 | | |
369 | 357 | | |
370 | 358 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
| 359 | + | |
| 360 | + | |
378 | 361 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2079 | 2079 | | |
2080 | 2080 | | |
2081 | 2081 | | |
2082 | | - | |
2083 | | - | |
2084 | 2082 | | |
2085 | 2083 | | |
2086 | 2084 | | |
| |||
2099 | 2097 | | |
2100 | 2098 | | |
2101 | 2099 | | |
2102 | | - | |
2103 | | - | |
2104 | | - | |
2105 | | - | |
2106 | | - | |
| 2100 | + | |
2107 | 2101 | | |
2108 | 2102 | | |
2109 | 2103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1623 | 1623 | | |
1624 | 1624 | | |
1625 | 1625 | | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
1626 | 1629 | | |
1627 | 1630 | | |
1628 | 1631 | | |
1629 | | - | |
1630 | | - | |
1631 | | - | |
| 1632 | + | |
| 1633 | + | |
1632 | 1634 | | |
1633 | 1635 | | |
1634 | 1636 | | |
| |||
1648 | 1650 | | |
1649 | 1651 | | |
1650 | 1652 | | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
1651 | 1683 | | |
1652 | 1684 | | |
1653 | 1685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
0 commit comments
Comments
(0)