Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

teradatasql: runtime/cgo: could not obtain pthread_keys

When I'm trying to read data from sqlalchemy df=pd.read_sql_table(table, con, schema) getting runtime error :

runtime/cgo: could not obtain pthread_keys tried 0x115 0x116 0x117 0x118 0x119 0x11a 0x11b 0x11c 0x11d 0x11e 0x11f 0x120 0x121 0x122 0x123 0x124 0x125 0x126 0x127 0x128 0x129 0x12a 0x12b 0x12c 0x12d 0x12e 0x12f 0x130 0x131 0x132 0x133 0x134 0x135 0x136 0x137 0x138 0x139 0x13a 0x13b 0x13c 0x13d 0x13e 0x13f 0x140 0x141 0x142 0x143 0x144 0x145 0x146 0x147 0x148 0x149 0x14a 0x14b 0x14c 0x14d 0x14e 0x14f 0x150 0x151 0x152 0x153 0x154 0x155 0x156 0x157 0x158 0x159 0x15a 0x15b 0x15c 0x15d 0x15e 0x15f 0x160 0x161 0x162 0x163 0x164 0x165 0x166 0x167 0x168 0x169 0x16a 0x16b 0x16c 0x16d 0x16e 0x16f 0x170 0x171 0x172 0x173 0x174 0x175 0x176 0x177 0x178 0x179 0x17a 0x17b 0x17c 0x17d 0x17e 0x17f 0x180 0x181 0x182 0x183 0x184 0x185 0x186 0x187 0x188 0x189 0x18a 0x18b 0x18c 0x18d 0x18e 0x18f 0x190 0x191 0x192 0x193 0x194

Below is the code:

class TeradataWriter:

    def __init__(self):
        print("in init")


    def read_data_from_teradata(self):
        try:
            print('Create  main')
            import pdb;pdb.set_trace()
            eng = self.create_connection_engine()

            df = pd.read_sql_table("table_name", eng, schema="schema")

            print(df)
        except Exception as ex:
            print('Exception: %s', ex.with_traceback())

    def create_connection_engine(self):

        try:
            return create_engine('teradatasql://' + constants.TERADATA_HOST + '/?user='+ constants.TERADATA_USER_NAME + '&password=' + constants.TERADATA_PWD, echo=False)
        except Exception as ex:
            LOGGER.error('Exception: %s', ex)
            raise Exception(message_constants.ERROR_WHILE_CREATING_CONNECTION_WITH_TERADATA)


if __name__ == "__main__":
    p = TeradataWriter()

    p.write_dataframe_to_teradata()
like image 539
Nishant Avatar asked Oct 21 '19 14:10

Nishant


1 Answers

Edit: This is fixed. I was finally able to get their support and engineering team to reproduce the issue. They now build the driver with a newer version of go. Upgrade to >= 17.0.3, and you shouldn't see anymore segfaults.

I think I finally figured out why this happens. According to this Go issue, it happens if "If the host process spawns threads prior to loading the shared library, the offset will have changed."

In my case, I was importing matplotlib.pyplot in IPython before calling code that loads the shared library. This starts an event loop and causes the conditions that lead to the segfault.

I changed my code to import matplotlib.pyplot after configuring the teradata driver, and it went away.

According to the Go issue, they just need to recompile the library with a newer version of Go, which I've asked them to do. We'll see what they say.

like image 86
jseabold Avatar answered Nov 06 '22 09:11

jseabold