Last active
September 19, 2019 03:52
-
-
Save krasio/761da3829988f3be1e371578ec6cef40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks=# BEGIN; | |
BEGIN | |
tasks=# SELECT * FROM tasks WHERE status = 'pending' ORDER BY created_at ASC LIMIT 1 FOR UPDATE SKIP LOCKED; | |
id | status | payload | created_at | |
----+---------+-------------------------------------------------------------------+---------------------------- | |
1 | pending | { "action": "feed", "animal": "panda", "food": "kaiserschmarrn" } | 2019-09-19 15:39:49.459537 | |
(1 row) | |
tasks=# SAVEPOINT task_1; | |
SAVEPOINT | |
tasks=# INSERT INTO projects (name) VALUES ('foobar'); | |
ERROR: null value in column "namespace_id" violates not-null constraint | |
DETAIL: Failing row contains (20, foobar, null). | |
tasks=# ROLLBACK TO SAVEPOINT task_1; | |
ROLLBACK | |
tasks=# UPDATE tasks SET status = 'failed' WHERE id='1'; | |
UPDATE 1 | |
tasks=# COMMIT; | |
COMMIT | |
tasks=# SELECT * FROM tasks; | |
id | status | payload | created_at | |
----+--------+-------------------------------------------------------------------+---------------------------- | |
1 | failed | { "action": "feed", "animal": "panda", "food": "kaiserschmarrn" } | 2019-09-19 15:39:49.459537 | |
(1 row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment