forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit21d9c3e
committed
Give SMgrRelation pointers a well-defined lifetime.
After calling smgropen(), it was not clear how long you could continueto use the result, because various code paths including cacheinvalidation could call smgrclose(), which freed the memory.Guarantee that the object won't be destroyed until the end of thecurrent transaction, or in recovery, the commit/abort record thatdestroys the underlying storage.smgrclose() is now just an alias for smgrrelease(). It closes filesand forgets all state except the rlocator, but keeps the SMgrRelationobject valid.A new smgrdestroy() function is used by rare places that know thereshould be no other references to the SMgrRelation.The short version: * smgrclose() is now just an alias for smgrrelease(). It releases resources, but doesn't destroy until EOX * smgrdestroy() now frees memory, and should rarely be used.Existing code should be unaffected, but it is now possible for code thathas an SMgrRelation object to use it repeatedly during a transaction aslong as the storage hasn't been physically dropped. Such code wouldnormally hold a lock on the relation.This also replaces the "ownership" mechanism of SMgrRelations with apin counter. An SMgrRelation can now be "pinned", which prevents itfrom being destroyed at end of transaction. There can be multiple pinson the same SMgrRelation. In practice, the pin mechanism is only usedby the relcache, so there cannot be more than one pin on the sameSMgrRelation. Except with swap_relation_files XXXAuthor: Thomas Munro, Heikki LinnakangasReviewed-by: Robert Haas <robertmhaas@gmail.com>Discussion:https://www.postgresql.org/message-id/CA%2BhUKGJ8NTvqLHz6dqbQnt2c8XCki4r2QvXjBQcXpVwxTY_pvA@mail.gmail.com1 parent6a8ffe8 commit21d9c3e
File tree
12 files changed
+183
-227
lines changed- src
- backend
- access/transam
- commands
- postmaster
- storage
- buffer
- freespace
- smgr
- utils/cache
- include
- storage
- utils
12 files changed
+183
-227
lines changedLines changed: 8 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
616 | 616 |
| |
617 | 617 |
| |
618 | 618 |
| |
619 |
| - | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
620 | 624 |
| |
621 | 625 |
| |
622 | 626 |
| |
| |||
627 | 631 |
| |
628 | 632 |
| |
629 | 633 |
| |
630 |
| - | |
631 |
| - | |
632 |
| - | |
633 | 634 |
| |
634 | 635 |
| |
635 | 636 |
| |
| |||
656 | 657 |
| |
657 | 658 |
| |
658 | 659 |
| |
659 |
| - | |
660 |
| - | |
| 660 | + | |
| 661 | + | |
661 | 662 |
| |
662 |
| - | |
| 663 | + | |
663 | 664 |
| |
664 | 665 |
| |
665 | 666 |
| |
|
Lines changed: 0 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1422 | 1422 |
| |
1423 | 1423 |
| |
1424 | 1424 |
| |
1425 |
| - | |
1426 |
| - | |
1427 |
| - | |
1428 |
| - | |
1429 |
| - | |
1430 |
| - | |
1431 |
| - | |
1432 |
| - | |
1433 |
| - | |
1434 |
| - | |
1435 |
| - | |
1436 |
| - | |
1437 |
| - | |
1438 |
| - | |
1439 |
| - | |
1440 |
| - | |
1441 |
| - | |
1442 |
| - | |
1443 |
| - | |
1444 | 1425 |
| |
1445 | 1426 |
| |
1446 | 1427 |
| |
|
Lines changed: 5 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
239 | 239 |
| |
240 | 240 |
| |
241 | 241 |
| |
242 |
| - | |
243 |
| - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
244 | 246 |
| |
245 |
| - | |
| 247 | + | |
246 | 248 |
| |
247 | 249 |
| |
248 | 250 |
| |
|
Lines changed: 7 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
462 | 462 |
| |
463 | 463 |
| |
464 | 464 |
| |
465 |
| - | |
466 |
| - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
467 | 469 |
| |
468 |
| - | |
| 470 | + | |
469 | 471 |
| |
470 | 472 |
| |
471 | 473 |
| |
| |||
951 | 953 |
| |
952 | 954 |
| |
953 | 955 |
| |
954 |
| - | |
955 |
| - | |
956 |
| - | |
957 |
| - | |
958 |
| - | |
| 956 | + | |
| 957 | + | |
959 | 958 |
| |
960 | 959 |
| |
961 | 960 |
| |
|
Lines changed: 10 additions & 22 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
934 | 934 |
| |
935 | 935 |
| |
936 | 936 |
| |
937 |
| - | |
938 |
| - | |
939 |
| - | |
940 |
| - | |
941 | 937 |
| |
942 | 938 |
| |
943 | 939 |
| |
| |||
1897 | 1893 |
| |
1898 | 1894 |
| |
1899 | 1895 |
| |
1900 |
| - | |
1901 | 1896 |
| |
1902 |
| - | |
1903 |
| - | |
1904 |
| - | |
1905 | 1897 |
| |
1906 | 1898 |
| |
1907 | 1899 |
| |
| |||
4155 | 4147 |
| |
4156 | 4148 |
| |
4157 | 4149 |
| |
| 4150 | + | |
4158 | 4151 |
| |
4159 | 4152 |
| |
4160 | 4153 |
| |
| |||
4183 | 4176 |
| |
4184 | 4177 |
| |
4185 | 4178 |
| |
4186 |
| - | |
| 4179 | + | |
4187 | 4180 |
| |
4188 | 4181 |
| |
4189 | 4182 |
| |
| |||
4229 | 4222 |
| |
4230 | 4223 |
| |
4231 | 4224 |
| |
4232 |
| - | |
| 4225 | + | |
4233 | 4226 |
| |
4234 | 4227 |
| |
4235 | 4228 |
| |
| |||
4442 | 4435 |
| |
4443 | 4436 |
| |
4444 | 4437 |
| |
4445 |
| - | |
4446 | 4438 |
| |
| 4439 | + | |
| 4440 | + | |
4447 | 4441 |
| |
4448 | 4442 |
| |
4449 | 4443 |
| |
4450 | 4444 |
| |
4451 | 4445 |
| |
| 4446 | + | |
| 4447 | + | |
| 4448 | + | |
4452 | 4449 |
| |
4453 | 4450 |
| |
4454 | 4451 |
| |
| |||
4465 | 4462 |
| |
4466 | 4463 |
| |
4467 | 4464 |
| |
4468 |
| - | |
| 4465 | + | |
4469 | 4466 |
| |
4470 |
| - | |
| 4467 | + | |
4471 | 4468 |
| |
4472 | 4469 |
| |
4473 | 4470 |
| |
| |||
4481 | 4478 |
| |
4482 | 4479 |
| |
4483 | 4480 |
| |
4484 |
| - | |
4485 |
| - | |
4486 |
| - | |
4487 |
| - | |
4488 |
| - | |
4489 |
| - | |
4490 |
| - | |
4491 |
| - | |
4492 |
| - | |
4493 | 4481 |
| |
4494 | 4482 |
| |
4495 | 4483 |
| |
|
Lines changed: 1 addition & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
532 | 532 |
| |
533 | 533 |
| |
534 | 534 |
| |
535 |
| - | |
536 |
| - | |
537 |
| - | |
538 |
| - | |
539 |
| - | |
540 |
| - | |
541 |
| - | |
542 |
| - | |
| 535 | + | |
543 | 536 |
| |
544 | 537 |
| |
545 | 538 |
| |
|
0 commit comments
Comments
(0)