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

(JP) GpuScanとGpuSortを行うSQLでSEGVすることがある #29

Closed
taiki-k opened this issue Jun 4, 2014 · 4 comments
Closed

(JP) GpuScanとGpuSortを行うSQLでSEGVすることがある #29

taiki-k opened this issue Jun 4, 2014 · 4 comments
Labels
bug developer confirmed the steps to reproduce the problem, and does not work as expected

Comments

@taiki-k
Copy link
Contributor

taiki-k commented Jun 4, 2014

#27 の再現確認の際に発生しました。

GpuScanとGpuSortが行われるSQLで、SIGSEGVが発生します。
SeqScanなど、GpuScan以外のPlanになると発生しません。

  • バックトレース
#0  0x0000000000669c62 in ExecEvalScalarVar (exprstate=0x116c7a0, econtext=0x116bd28, isNull=0x116c338 "", isDone=0x0)
    at execQual.c:627
#1  0x000000000066c6a1 in ExecMakeFunctionResultNoSets (fcache=0x116bf88, econtext=0x116bd28, isNull=0x7ffffc57cb06 "", isDone=0x0)
    at execQual.c:1961
#2  0x000000000066d24e in ExecEvalOper (fcache=0x116bf88, econtext=0x116bd28, isNull=0x7ffffc57cb06 "", isDone=0x0) at execQual.c:2406
#3  0x0000000000673b75 in ExecQual (qual=0x116c8c0, econtext=0x116bd28, resultForNull=0 '\000') at execQual.c:5155
#4  0x00007fae48d2342c in gpuscan_exec_multi (node=0x116bb10) at gpuscan.c:1611
#5  0x0000000000680e46 in MultiExecCustomPlan (cpstate=0x116bb10) at nodeCustom.c:44
#6  0x0000000000668d31 in MultiExecProcNode (node=0x116bb10) at execProcnode.c:573
#7  0x00007fae48d29c19 in gpusort_preload_subplan_bulk (gsortstate=0x116b740, overflow=0x7ffffc57ce20) at gpusort.c:1349
#8  0x00007fae48d2b487 in gpusort_exec (node=0x116b740) at gpusort.c:1800
#9  0x0000000000680dcb in ExecCustomPlan (cpstate=0x116b740) at nodeCustom.c:37
#10 0x0000000000668ae5 in ExecProcNode (node=0x116b740) at execProcnode.c:453
#11 0x000000000066652c in ExecutePlan (estate=0x116b628, planstate=0x116b740, operation=CMD_SELECT, sendTuples=1 '\001',
    numberTuples=0, direction=ForwardScanDirection, dest=0x1173220) at execMain.c:1475
#12 0x00000000006643dc in standard_ExecutorRun (queryDesc=0x10cd948, direction=ForwardScanDirection, count=0) at execMain.c:308
#13 0x000000000066421f in ExecutorRun (queryDesc=0x10cd948, direction=ForwardScanDirection, count=0) at execMain.c:256
#14 0x00000000007f9e7e in PortalRunSelect (portal=0x10c9f08, forward=1 '\001', count=0, dest=0x1173220) at pquery.c:946
#15 0x00000000007f9aa5 in PortalRun (portal=0x10c9f08, count=9223372036854775807, isTopLevel=1 '\001', dest=0x1173220,
    altdest=0x1173220, completionTag=0x7ffffc57d290 "") at pquery.c:790
#16 0x00000000007f3212 in exec_simple_query (
    query_string=0x11143d8 "select * from bytea_test where bin between '\\xff00'::bytea and '\\xffff'::bytea order by id;")
    at postgres.c:1045
#17 0x00000000007f7992 in PostgresMain (argc=1, argv=0x10a4a60, dbname=0x10a48c0 "pgstrom_test", username=0x10a48a0 "tkondo")
    at postgres.c:4004
#18 0x000000000076e8e9 in BackendRun (port=0x10cf750) at postmaster.c:4117
#19 0x000000000076df9f in BackendStartup (port=0x10cf750) at postmaster.c:3791
#20 0x000000000076a366 in ServerLoop () at postmaster.c:1570
#21 0x00000000007699b9 in PostmasterMain (argc=1, argv=0x10a3430) at postmaster.c:1223
#22 0x00000000006b9166 in main (argc=1, argv=0x10a3430) at main.c:227
  • 実行したSQL
SELECT * FROM bytea_test WHERE bin BETWEEN '\xff00'::bytea AND '\xffff'::bytea ORDER BY id;
  • 対象のテーブル
  Table "public.bytea_test"
 Column |  Type  | Modifiers
--------+--------+-----------
 id     | bigint | not null
 bin    | bytea  |
Indexes:
    "bytea_test_pkey" PRIMARY KEY, btree (id)
  • 実行時プラン
pgstrom_test=# explain select * from bytea_test where bin between '\xff00'::bytea and '\xffff'::bytea order by id;
INFO:  now ready to run bulk-load
                                      QUERY PLAN
--------------------------------------------------------------------------------------
 Custom (GpuSort)  (cost=129673.73..129721.27 rows=19019 width=40)
   Sort keys: id
   Sort keys width: 8
   Rows per chunk: 21404
   ->  Custom (GpuScan) on bytea_test  (cost=10000.00..129660.21 rows=19019 width=40)
         Filter: ((bin >= '\xff00'::bytea) AND (bin <= '\xffff'::bytea))
         Host References: id, bin
         Device References:
         Filter: ((bin >= '\xff00'::bytea) AND (bin <= '\xffff'::bytea))
 Planning time: 1.548 ms
@taiki-k
Copy link
Contributor Author

taiki-k commented Jun 6, 2014

最新のコードで確認したところ、再現しなくなりました。
修正されたものと判断します。

@taiki-k taiki-k closed this as completed Jun 6, 2014
@taiki-k
Copy link
Contributor Author

taiki-k commented Jun 6, 2014

申し訳ありません。PlanがSeqScanとなった状態での再現評価となっていました。
GpuScanとした状態で再現確認したところ、再現しましたのでreopenします。

@taiki-k taiki-k reopened this Jun 6, 2014
@kaigai
Copy link
Contributor

kaigai commented Jun 6, 2014

GpuSort + GpuScan でデータを Bulk-load する場合でかつ、ホスト側で実行する条件句を含む場合、
ホスト側条件句を評価する ExecQual() 関数が正しく呼び出されていませんでした。
(ExprContext の ecxt_scantuple にスキャンした行をセットしてから呼ばねばならない)

その結果、NULL参照でSEGVとなっていたようです。最新版で直しています。

@taiki-k
Copy link
Contributor Author

taiki-k commented Jun 6, 2014

最新版で確認したところ、SEGVはしなくなりましたが、
エラーメッセージが表示され、SQL文の実行ができませんでした。

エラーメッセージが表示される件は、別の問題のようですので分割( #32 )し、
こちらはクローズします。

@taiki-k taiki-k closed this as completed Jun 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug developer confirmed the steps to reproduce the problem, and does not work as expected
Projects
None yet
Development

No branches or pull requests

2 participants