forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0f12905
committed
Count individual SQL commands in pg_restore's --transaction-size mode.
The initial implementation in commit959b38d counted one actionper TOC entry (except for some special cases for multi-blob BLOBSentries). This assumes that TOC entries are all about equallycomplex, but it turns out that that assumption doesn't hold up verywell in binary-upgrade mode. For example, even after the previouscommit I was able to cause backend bloat with tables having manyinherited constraints. There may be other cases too. (Since noserious problems have been reported with --single-transaction mode,we can conclude that the backend copes well with psql's regularrestore scripts; but before959b38d we never ran binary-upgraderestores with multi-command transactions.)To fix, count multi-command TOC entries as N actions, allowing thetransaction size to be scaled down when we hit a complex TOC entry.Rather than add a SQL parser to pg_restore, approximate "multicommand" by counting semicolons in the TOC entry's defn string.This will be fooled by semicolons appearing in string literals ---but the error is in the conservative direction, so it doesn't seemworth working harder. The biggest risk is with function/procedureTOC entries, but we can just explicitly skip those.(This is undoubtedly a hack, and maybe someday we'll be able torevert it after fixing the backend's bloat issues or rethinkingwhat pg_dump emits in binary upgrade mode. But that surely isn'ta project for v17.)Thanks to Alexander Korotkov for the let's-count-semicolons idea.Per report from Justin Pryzby. Back-patch to v17 where txn_size modewas introduced.Discussion:https://postgr.es/m/ZqEND4ZcTDBmcv31@pryzbyj20231 parentb3f0e05 commit0f12905
1 file changed
+25
-3
lines changedLines changed: 25 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3827 | 3827 |
| |
3828 | 3828 |
| |
3829 | 3829 |
| |
3830 |
| - | |
| 3830 | + | |
3831 | 3831 |
| |
3832 |
| - | |
3833 |
| - | |
| 3832 | + | |
| 3833 | + | |
| 3834 | + | |
| 3835 | + | |
| 3836 | + | |
| 3837 | + | |
| 3838 | + | |
| 3839 | + | |
| 3840 | + | |
| 3841 | + | |
| 3842 | + | |
| 3843 | + | |
| 3844 | + | |
| 3845 | + | |
| 3846 | + | |
| 3847 | + | |
| 3848 | + | |
| 3849 | + | |
| 3850 | + | |
| 3851 | + | |
| 3852 | + | |
| 3853 | + | |
| 3854 | + | |
| 3855 | + | |
3834 | 3856 |
| |
3835 | 3857 |
| |
3836 | 3858 |
| |
|
0 commit comments
Comments
(0)