Skip to content

Transactions aren't forwarded without DDL statements #173

Description

@flip-rossi

The Quack docs state that transactions are forwarded on attached peers, but it seems something like BEGIN; ...; INSERT INTO quackpeer.t VALUES ('hello'); COMMIT; only works transactionally if there was some DDL statement such as CREATE TABLE quackpeer.othert (v INT) within ... before the insertion.

Steps to reproduce

Setup server:

CREATE TABLE t1 (v INT);
CALL quack_serve('quack:localhost',token:='1234');

On client:

ATTACH 'quack:localhost' AS peer (TOKEN '1234');

-- TRANSACTION 1: Quack doesn't actually start a multi-statement transaction
BEGIN;
INSERT INTO peer.t1 VALUES (1);
FROM peer.t1;
-- ┌───────┐
-- │   v   │
-- │ int32 │
-- ├───────┤
-- │     1 │ <- OK: inserted this commit
-- └───────┘
ROLLBACK;
FROM peer.t1;
-- ┌───────┐
-- │   v   │
-- │ int32 │
-- ├───────┤
-- │     1 │ <- should've been rolled back
-- └───────┘

-- TRANSACTION 2: Quack starts multi-statement transaction after DDL statement
BEGIN;
CREATE TABLE peer.t2 (v INT);
INSERT INTO peer.t1 VALUES (2);
FROM peer.t1;
-- ┌───────┐
-- │   v   │
-- │ int32 │
-- ├───────┤
-- │     1 │
-- │     2 │ <- OK: inserted this commit
-- └───────┘
ROLLBACK;
FROM peer.t1;
-- ┌───────┐
-- │   v   │
-- │ int32 │
-- ├───────┤
-- │     1 │
-- └───────┘ <- OK: insertion of '2' was rolled back

Note that the table created in TRANSACTION 2 wasn't even the one we inserted into!

You can also verify that even before TRANSACTION 1 should finish, row 1 is readable for other peers/the server, and even before TRANSACTION 2 rolls back, row 2 isn't visible for anyone else other than the client that inserted it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions