heterodb / pg-strom

PG-Strom - Master development repository
http://heterodb.github.io/pg-strom/
Other
1.27k stars 163 forks source link

[GPU Logic Bug] SELECT <columns> FROM <table> JOIN <table> Brings GPU Logic Bug #785

Closed qwebug closed 2 weeks ago

qwebug commented 3 weeks ago

Describe:

SELECT \ FROM \

JOIN \
brings different results, when using CPU-only configurations and GPU-used configurations.

SQL with CPU-only Config:

CREATE TABLE t2(c1 serial) ;
CREATE TABLE t3(LIKE t2);
INSERT INTO t2(c1) OVERRIDING SYSTEM VALUE VALUES(1), (2);
INSERT INTO t3(c1) VALUES(0), (0);
CREATE SCHEMA extensions;
CREATE EXTENSION pg_strom WITH SCHEMA extensions;
SET pg_strom.enabled=off;
SELECT t2.c1 FROM t2 LEFT OUTER JOIN t3 ON CAST(t2.c1 AS BOOLEAN);

Result:

 c1 
----
  1
  1
  2
  2
(4 rows)

SQL with GPU-used Config:

BEGIN;
SET LOCAL pg_strom.enabled=on; 
SET LOCAL pg_strom.enable_gpuscan=on; 
SET LOCAL pg_strom.enable_gpujoin=on; 
SELECT t2.c1 FROM t2 LEFT OUTER JOIN t3 ON CAST(t2.c1 AS BOOLEAN);
COMMIT;

Result:

 c1 
----
  1
  2
  1
  2
(4 rows)

Environment:

Pg-strom Version: commit b1f04e4042a8990ee9b21263f08365982b5495b5

PostgreSQL Version: 15.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20), 64-bit

CUDA Version: 12.2

NVIDIA Driver Version: 535.171.04

kaigai commented 2 weeks ago

This is not a bug but by design.

As introduced at #781, PostgreSQL does not guarantee the order of results. So, the above output difference is reasonable.

hoge=# set pg_strom.enabled = off;
SET
hoge=# SELECT t2.ctid, t2.c1 FROM t2 LEFT OUTER JOIN t3 ON CAST(t2.c1 AS BOOLEAN);
 ctid  | c1
-------+----
 (0,1) |  1
 (0,1) |  1
 (0,2) |  2
 (0,2) |  2
(4 rows)

hoge=# set pg_strom.enabled = on;
SET
hoge=# SELECT t2.ctid, t2.c1 FROM t2 LEFT OUTER JOIN t3 ON CAST(t2.c1 AS BOOLEAN);
 ctid  | c1
-------+----
 (0,1) |  1
 (0,2) |  2
 (0,1) |  1
 (0,2) |  2
(4 rows)