Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bsD37-0005qs-55 for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Oct 2016 18:05:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bsD36-00064N-I9 for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Oct 2016 18:05:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bsD35-00064G-U3 for pgsql-bugs@postgresql.org; Thu, 06 Oct 2016 18:05:40 +0000 Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bsD32-0002vM-GW for pgsql-bugs@postgresql.org; Thu, 06 Oct 2016 18:05:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20140207; h=Content-Type:MIME-Version:Reply-To:Message-ID:Subject:To: Sender:From:Date:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=4SZ6PePzH/T782Qep6FLIih35iBfR4Y4A58c0+7+/S4=; b=s8rkAzc25wZ/pIE/eW/uTy9c2Q RyN3uUkiRqKRe2aAMwXy9ERQ/Yf4le7AelP1XSgqVhKwvVgVD81SIOY23E2iV8O7aycqoez1GGzVS jL4Sp8XUtaFZaT7oYvBFb10m3; Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by depesz.com with esmtpa (Exim 4.87) (envelope-from ) id 1bsD2z-0000aF-Gs for pgsql-bugs@postgresql.org; Thu, 06 Oct 2016 20:05:33 +0200 Date: Thu, 6 Oct 2016 20:05:33 +0200 From: hubert depesz lubaczewski To: PostgreSQL Bugs Subject: Rows go missing when selecting "for update" after savepoint "play" Message-ID: <20161006180533.5wq6fcqbdeam3tib@depesz.com> Reply-To: depesz@depesz.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: NeoMutt/20160916 (1.7.0) X-Pg-Spam-Score: -4.6 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Used postgresql: 9.5.4 (from pgdg apt archive) system: ubuntu trusty repeatable case: CREATE TABLE depesz (id serial PRIMARY KEY, x TEXT); BEGIN; INSERT INTO depesz (id, x) VALUES (1,'x'); SELECT * FROM depesz WHERE id = 1 for UPDATE; UPDATE depesz SET x = 'y' WHERE id = 1; savepoint i_hate_activerecord; SELECT * FROM depesz WHERE id = 1 for UPDATE; UPDATE depesz SET x = 'aa' WHERE id = 1; rollback to SAVEPOINT i_hate_activerecord; SELECT * FROM depesz WHERE id = 1; SELECT * FROM depesz WHERE id = 1 for UPDATE; -- here is the problem SELECT * FROM depesz WHERE id = 1; rollback; DROP TABLE depesz; on my test system running it looks like: CREATE TABLE depesz (id serial PRIMARY KEY, x TEXT); CREATE TABLE BEGIN; BEGIN INSERT INTO depesz (id, x) VALUES (1,'x'); INSERT 0 1 SELECT * FROM depesz WHERE id = 1 for UPDATE; id | x ----+--- 1 | x (1 row) UPDATE depesz SET x = 'y' WHERE id = 1; UPDATE 1 savepoint i_hate_activerecord; SAVEPOINT SELECT * FROM depesz WHERE id = 1 for UPDATE; id | x ----+--- 1 | y (1 row) UPDATE depesz SET x = 'aa' WHERE id = 1; UPDATE 1 rollback to SAVEPOINT i_hate_activerecord; ROLLBACK SELECT * FROM depesz WHERE id = 1; id | x ----+--- 1 | y (1 row) SELECT * FROM depesz WHERE id = 1 for UPDATE; id | x ----+--- (0 rows) SELECT * FROM depesz WHERE id = 1; id | x ----+--- 1 | y (1 row) rollback; ROLLBACK DROP TABLE depesz; DROP TABLE I think that the marked select for update should return 1 row, because - well, why wouldn't it? I checked, and the problem is not there in 10.devel. Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/ -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs