From: | Zhang Mingli <zmlpostgres(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Add more docs for pg_surgery? |
Date: | 2022-09-26 15:59:19 |
Message-ID: | 698ffd5b-dc40-4a91-8666-e962411065f5@Spark |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi, hackers
heap_force_kill/heap_force_freeze doesn’t consider other transactions that are using the same tuples even with tuple-locks.
The functions may break transaction semantic, ex:
session1
```
create table htab(id int);
insert into htab values (100), (200), (300), (400), (500);
```
session2
```
begin isolation level repeatable read;
select * from htab for share;
id
-----
100
200
300
400
500
(5 rows)
```
session1
```
select heap_force_kill('htab'::regclass, ARRAY['(0, 1)']::tid[]);
heap_force_kill
-----------------
(1 row)
```
session2
```
select * from htab for share;
id
-----
200
300
400
500
(4 rows)
```
session2 should get the same results as it's repeatable read isolation level.
By reading the doc:
```
The pg_surgery module provides various functions to perform surgery on a damaged relation. These functions are unsafe by design and using them may corrupt (or further corrupt) your database. For example, these functions can easily be used to make a table inconsistent with its own indexes, to cause UNIQUE or FOREIGN KEY constraint violations, or even to make tuples visible which, when read, will cause a database server crash. They should be used with great caution and only as a last resort.
```
I know they are powerful tools, but also a little surprise with the above example.
Should we add more docs to tell the users that the tool will change the tuples anyway even there are tuple-locks on them?
Regards,
Zhang Mingli
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Bossart | 2022-09-26 16:08:22 | Re: identifying the backend that owns a temporary schema |
Previous Message | Andres Freund | 2022-09-26 15:41:03 | Re: [RFC] building postgres with meson - v13 |