This repository was archived by the owner on Nov 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
This repository was archived by the owner on Nov 19, 2021. It is now read-only.
Segmentation fault when work table present #88
Copy link
Copy link
Open
Description
Giraffez core dumps with Segmentation fault error when giraffez.BulkLoad is called but a work table is present.
Steps to reproduce:
- Create a test database:
CREATE DATABASE demo_db AS PERMANENT = 60e6, SPOOL = 60e6; - Execute the following python script. You may have to edit
td_connectionto point to your Vantage database instance.
The script drops tabledemo_db.test_table_wtand then creates it. It then runsgiraffez.BulkLoadagainstdemo_db.test_table. With this naming convention, the script pretends that the work table is always there.import giraffez td_connection = { "host": "localhost", "username": "dbc", "password": "dbc" } try: with giraffez.Cmd(**td_connection) as cmd: cmd.execute("DROP TABLE demo_db.test_table_wt") except Exception: pass create_ddl = "create multiset table demo_db.test_table_wt(\ INDEX_ID BIGINT)" with giraffez.Cmd(**td_connection) as cmd: cmd.execute(create_ddl) show_ddl = cmd.execute("SHOW TABLE demo_db.test_table_wt") print(list(show_ddl)) f = open("/tmp/temp.csv", "w") f.write("1") f.close() with giraffez.BulkLoad(**td_connection, table="demo_db.test_table") as load: load.from_file( "/tmp/temp.csv", delimiter="," ) - Result:
[Row({'request_text': 'CREATE MULTISET TABLE demo_db.test_table_wt ,FALLBACK ,\r NO BEFORE JOURNAL,\r NO AFTER JOURNAL,\r CHECKSUM = DEFAULT,\r DEFAULT MERGEBLOCKRATIO,\r MAP = TD_MAP1\r (\r index_id BIGINT)\rPRIMARY INDEX ( index_id );'})] Segmentation fault (core dumped)
I've looked at the core dump. Backtrace points to giraffez/src/teradatapt.hpp:296 at if (err->Code == TD_SUCCESS):
PyObject* Exists(const char *tbl_name) {
TeradataErr *err = NULL;
PyObject *ret;
ret = Py_False;
Py_INCREF(ret);
std::string query = "show table " + std::string(tbl_name);
if ((err = this->ExecuteCommand(query, false)) != NULL) {
if (err->Code != TD_ERROR_OBJECT_NOT_EXIST) {
return NULL;
}
PyErr_Clear();
}
if (err->Code == TD_SUCCESS) {
// TODO: ref correct?
ret = Py_True;
}
return ret;
}
When a work table exists ExecuteCommand() returns NULL. As a result, err object is also NULL. Line 296 then references memory address 0.
Many thanks to @acirtep for helping me identify the issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels