Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Effects of TRUNCATE persists even after ROLLBACK #15900

Closed
Karvy-yb opened this issue Jan 31, 2023 · 2 comments
Closed

[YSQL] Effects of TRUNCATE persists even after ROLLBACK #15900

Karvy-yb opened this issue Jan 31, 2023 · 2 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) duplicate kind/bug This issue is a bug priority/high High Priority QA QA filed bugs

Comments

@Karvy-yb
Copy link

Karvy-yb commented Jan 31, 2023

Jira Link: DB-5304

Description

Steps to reproduce:

  1. create database test;
  2. \c test
  3. create table tb_test(k int);
  4. insert into tb_test values (1), (2), (3);
  5. select * from tb_test;
  6. begin transaction;
  7. truncate tb_test;
  8. select * from tb_test;
  9. rollback;
  10. select * from tb_test;

The result will still return empty table even though the TRUNCATE statement has been rolledback. Postgres treats TRUNCATE as DML and thus I was able to rollback TRUNCATE command.

Even if we don't allow rollback of TRUNCATE, we should specify that as a warning here.

@Karvy-yb Karvy-yb added area/ysql Yugabyte SQL (YSQL) priority/high High Priority QA QA filed bugs status/awaiting-triage Issue awaiting triage labels Jan 31, 2023
@yugabyte-ci yugabyte-ci added the kind/bug This issue is a bug label Jan 31, 2023
@ddorian
Copy link
Contributor

ddorian commented Jan 31, 2023

From postgresql docs https://www.postgresql.org/docs/11/sql-truncate.html:

TRUNCATE is not MVCC-safe. After truncation, the table will appear empty to concurrent transactions, if they are using a snapshot taken before the truncation occurred. See Section 13.5 for more details.

TRUNCATE is transaction-safe with respect to the data in the tables: the truncation will be safely rolled back if the surrounding transaction does not commit.

@jasonyb
Copy link
Contributor

jasonyb commented Jan 31, 2023

Duplicate of #1404

@jasonyb jasonyb marked this as a duplicate of #1404 Jan 31, 2023
@jasonyb jasonyb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2023
@yugabyte-ci yugabyte-ci removed the status/awaiting-triage Issue awaiting triage label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) duplicate kind/bug This issue is a bug priority/high High Priority QA QA filed bugs
Projects
None yet
Development

No branches or pull requests

5 participants