The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.

Seg fault when connecting to vertica

I'm getting a seg fault whenever I try to connect to vertica in my Python application. Here's the odbctrace log that shows the error I'm getting, IM0004. [ODBC][5140][1369066167.535663][SQLConnect.c][1297]Error: IM004 [ODBC][5140][1369066167.535816][SQLDriverConnect.c][687] Entry: Connection = 0x2030e60 Window Hdl = (nil) Str In = [uid=dbadmin;database=vertica01;DRIVER=vertica;label=Python database library (no app name specified);cluster=vertica01;pwd=cfaust...][length = 158 (SQL_NTS)] Str Out = 0x7fff8e29ea80 Str Out Max = 2048 Str Out Ptr = (nil) Completion = 0 UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE' Are there any further things I can do to help diagnose what the issue might be? Details ================ System: Ubuntu 12.04.1 LTS Vertica: 6.1.1 $ uname -a Linux starfish01 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Comments

  • Hi Amy Sorry to hear about your trouble. Here are some things we can do to further diagnose this problem. The error IM004 means that the driver manager failed to allocate an environment handle. The environment handle is the main entry point to our driver. The python library first allocates an environment, and from that environment it allocates connections. If it fails this early, it is likely a sign of an incorrect configuration. So let's take python out of the picture for a moment, and focus on the UnixODBC Driver Manager & ODBC driver configuration. Can you post the output of "odbcinst -j"? This will print out some information about the UnixODBC driver manager installed on your system. This prints the driver manager's version, some info on how it was built, and the location of various configuration files. Can you also post your configuration files (odbcinst.ini, odbc.ini & vertica.ini)? The location and the appropriate configuration for these files are described in the following pages: https://my.vertica.com/docs/CE/6.0.1/HTML/index.htm#11705.htm https://my.vertica.com/docs/CE/6.0.1/HTML/index.htm#17045.htm When these files are defined properly, you should be able to use the isql utility bundled with UnixODBC to connect to Vertica and issue queries. There is an example of doing this here: https://my.vertica.com/docs/CE/6.0.1/HTML/index.htm#17220.htm This should rule out any configuration issues. If you can connect with isql, we'll have to dig a little deeper. Tom
  • Thanks for all the information. It definitely was a configuration issue. I had my VERTICAINI set to a file configured for OS X and iODBC. When I changed it to point at our system /etc/vertica.ini file things worked perfectly.
  • Ugh now I'm getting the error again, this time as a different user, and I can't figure out why. $ ./test.py Segmentation fault $ echo $VERTICAINI /etc/vertica.ini $ cat /etc/vertica.ini [Driver] DriverManagerEncoding=UTF-32 ODBCInstLib=/usr/lib/x86_64-linux-gnu/libodbcinst.so ErrorMessagesPath=/opt/vertica/lib64 LogLevel=4 LogPath=/tmp $ odbcinst -j unixODBC 2.2.14 DRIVERS............: /etc/odbcinst.ini SYSTEM DATA SOURCES: /etc/odbc.ini FILE DATA SOURCES..: /etc/ODBCDataSources USER DATA SOURCES..: /home/apiservice/.odbc.ini SQLULEN Size.......: 8 SQLLEN Size........: 8 SQLSETPOSIROW Size.: 8 $ cat /etc/odbcinst.ini [vertica] Description = "Vertica DSN" Driver = /opt/vertica/lib64/libverticaodbc.so Setup = /opt/vertica/lib64/libverticaodbc.so $ ls /opt/vertica/lib64/ en-US libverticaodbc.so libverticaodbc.so.6 libverticaodbc.so.6.1 libverticaodbc.so.6.1.1 $ isql -v vertica [IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified [ISQL]ERROR: Could not SQLConnect
  • $ ls /etc/ODBCDataSources $ ls /home/apiservice/.odbc.ini ls: cannot access /home/apiservice/.odbc.ini: No such file or directory
  • $ cat /etc/odbc.ini [ODBC Data Sources] vertica = "vertica server" [ODBC] Threading = 1 Trace = 1 TraceFile = /tmp/odbctrace.log Debug = 1 DebugFile = /tmp/odbcdebug.log
  • Hi Amy I see a few problems with your configuration. What you have is close, but you you haven't defined a DSN (Data source name). There are also a couple of smaller issues that would cause trouble later on. Let me go over each file and explain what's going on. odbcinst.ini is meant to be a centralized spot for defining the ODBC drivers installed on your system. In your example, you've create a driver called "vertica" and provided a path to our ODBC driver library with the "Driver = /opt/vertica/lib64/libverticaodbc.so" line. This part is correct. The next line, "Setup = /opt/vertica/lib64/libverticaodbc.so" line should be removed. Some drivers provide an ODBC setup library, which can provide a GUI for configuring a connection. Vertica's ODBC driver does not come with one. The odbc.ini file defines DSNs (data source names), which define a particular connection to a database using a driver. The [ODBC Data Sources] section is a heading that defines the DSNs in the file and provides a brief description of its intended use. Beneath that, for each DSN defined in the [ODBC Data Sources] section, there should be [dsn-name] Driver=(driver name, as defined in odbcinst.ini) (additional DSN settings) Finally, In your vertica.ini: DriverManagerEncoding should be UTF-16 and not UTF-32, because your unixODBC was built with two byte unicode characters. This isn't causing problems yet, but it would once you get the DSN straightened out. Here is an example of each that should work for you once you fill in the proper DSN info: $ cat /etc/vertica.ini [Driver] # path to the unixODBC driver manager .so ODBCInstLib=/usr/lib/x86_64-linux-gnu/libodbcinst.so # The unicode encoding the ODBCInstLib was built with DriverManagerEncoding=UTF-16 #path to the ODBC driver's localized error messages ErrorMessagesPath=/opt/vertica/lib64 #Driver logging settings #only enable logging to debug issues; otherwise it may slow things down LogLevel=4 LogPath=/tmp $ cat /etc/odbcinst.ini [Vertica] Description = "Vertica ODBC driver" Driver = /opt/vertica/lib64/libverticaodbc.so $ cat /etc/odbc.ini [ODBC Data Sources] MyVerticaDSN = Description for MyVerticaDSN [MyVerticaDSN] # This refers to the [Vertica] entry in /etc/odbcinst.ini Driver=Vertica UID=amy Servername=verticahost.com Port=5433 Database=dbname # Add additional DSN options here if necessary # see https://my.vertica.com/docs/CE/6.0.1/HTML/index.htm#12800.htm for the full list #Driver manager settings [ODBC] Threading = 1 Trace = 1 TraceFile = /tmp/odbctrace.log Debug = 1 DebugFile = /tmp/odbcdebug.log Sorry for the confusion. Hopefully with all this you should be able to get connected! Tom
  • Ok so I finally managed to get our IT person to change the vertica.ini and odbcinst.ini on our servers and was able to do some more testing on this issue. I am still getting seg faults. Here's the odbctrace.log: [ODBC][22253][1371052611.493602][SQLDriverConnectW.c][286] Entry: Connection = 0x28e3100 Window Hdl = (nil) Str In = [uid=dbadmin;database=vertica01;DRIVER=vertica;label=Python database library (no app name specified);cluster=vertica01;pwd=cfaust...][length = 158] Str Out = (nil) Str Out Max = 0 Str Out Ptr = (nil) Completion = 0 UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE' [ODBC][22253][1371052611.496432][SQLConnect.c][1297]Error: IM004 [ODBC][22253][1371052611.496482][SQLDriverConnect.c][687] Entry: Connection = 0x28e3100 Window Hdl = (nil) Str In = [uid=dbadmin;database=vertica01;DRIVER=vertica;label=Python database library (no app name specified);cluster=vertica01;pwd=cfaust...][length = 158 (SQL_NTS)] Str Out = 0x7fff41eba880 Str Out Max = 2048 Str Out Ptr = (nil) Completion = 0 UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE' I also don't think we need to provide any DSN information in the odbc.ini file as we are connecting with a Connection String which provides all such information. We are using the pyodbc library to connect with the following settings: autocommit: True database: 'vertica01' driver: 'vertica' label: 'Python database library' cluster: 'vertica01' host: 'vertica02' user: 'dbadmin' password: 'XXXX' port: 5433 Information on how pyodbc creates a Connection String from these parameters here: http://code.google.com/p/pyodbc/wiki/Module#connect Further details: $ echo $VERTICAINI /etc/vertica.ini $ cat /etc/vertica.ini [Driver] DriverManagerEncoding=UTF-16 ODBCInstLib=/usr/lib/x86_64-linux-gnu/libodbcinst.so ErrorMessagesPath=/opt/vertica/lib64 LogLevel=4 LogPath=/tmp $ cat /etc/odbcinst.ini [vertica] Description = "Vertica DSN" Driver = /opt/vertica/lib64/libverticaodbc.so $ odbcinst -j unixODBC 2.2.14 DRIVERS............: /etc/odbcinst.ini SYSTEM DATA SOURCES: /etc/odbc.ini FILE DATA SOURCES..: /etc/ODBCDataSources # this file doesn't exist USER DATA SOURCES..: /users/me/.odbc.ini # this file doesn't exist SQLULEN Size.......: 8 SQLLEN Size........: 8 SQLSETPOSIROW Size.: 8 Just for kicks, and so we can test with isql, I added a /users/me/.odbc.ini file with the following contents: $ cat /users/me/.odbc.ini [test] Driver=Vertica Servername=vertica01 Database=vertica01 Port=5433 UID=dbadmin PWD=XXXX And with this additional file (which is not what we will ultimately be using in production) I get the following output from isql: $ isql -v test [28000][unixODBC]FATAL 3781: Invalid username or password [ISQL]ERROR: Could not SQLConnect I've checked that the username and password is correct and it definitely is. I am able to connect perfectly well from our OS X machines using the very same username name and password.
  • Hi! >> I also don't think we need to provide any DSN information in the odbc.ini file as we are connecting with a Connection String which provides all such information. Your connection string doesn't provide information about driver for example, so you must to define a DNS. >> cluster=vertica01;pwd=cfaust... Be careful, your info includes a password. >> [28000][unixODBC]FATAL 3781: Invalid username or password Instead of 'UID' and 'PWD' try to define: 'UserName' ans 'Password' in odbc.ini Take a look here: http://vertica-forums.com/viewtopic.php?f=21&t=294&p=3953&hilit=odbc#p3953
  • Amy, did you ever solve this? I'm getting a segfault when running my python program's unit tests, and I'm looking for things to try.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.