osdldbt / dbt5

Database Test 5: Fair Use TPC Benchmark(TM) E
Artistic License 2.0
1 stars 10 forks source link

Build issues on Debian #11

Closed karim-manaouil closed 3 months ago

karim-manaouil commented 7 months ago

I have a debian 12 with libpq-dev and the library installed.

I always get those build issues when I try to build tpc-e tools:

s/SecurityDetailDB.o transactions/TradeCleanupDB.o transactions/TradeLookupDB.o transactions/TradeOrderDB.o transactions/TradeResultDB.o transactions/TradeStatusDB.o transactions/TradeUpdat
eDB.o transactions/TxnBaseDB.o \                                                                                                                                                             
                        DateTime.o error.o Random.o Money.o EGenVersion.o locking.o threading.o condition.o \                                                                                
                        interfaces/DMSUTtest.o interfaces/MEESUTtest.o TestTransactions/TestTxn.o interfaces/TxnHarnessSendToMarketTest.o \                                                  
                        ../lib/libegen.a \                                                                                                                                                   
                         \                                                                                                                                                                   
                        -o ../bin/TestTxn; \                                                                                                                                                 
cd ../prj; \                                                                                                                                                                                 
ls -l ../bin                                                                                                                                                                                 
total 7552                                                                                                                                                                                   
drwxr-xr-x  2 root root    4096 Feb 16 13:16 .                                                                                                                                               
drwxr-xr-x 15 root root    4096 Feb 16 13:16 ..                                                                                                                                              
-rw-r--r--  1 root root       0 Feb 16 13:16 BrokerageHouseMain                                                                                                                              
-rw-r--r--  1 root root       0 Feb 16 13:16 DriverMain                                                                                                                                      
-rwxr-xr-x  1 root root 6645312 Feb 16 13:16 EGenLoader                                                                                                                                      
-rwxr-xr-x  1 root root  749480 Feb 16 13:16 EGenValidate                                                                                                                                    
-rw-r--r--  1 root root 4095527 Feb 16 13:16 MarketExchangeMain                                                                                                                              
-rw-r--r--  1 root root       0 Feb 16 13:16 TestTxn                                                                                                                                         
/usr/bin/ld: transactions/pgsql/DBConnection.o: in function `CDBConnection::CDBConnection(char const*, char const*, char const*)':
/root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:120: undefined reference to `PQconnectdb'            
/usr/bin/ld: transactions/pgsql/DBConnection.o: in function `CDBConnection::~CDBConnection()':                                                                                               
/root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:126: undefined reference to `PQfinish'               
/usr/bin/ld: transactions/pgsql/DBConnection.o: in function `CDBConnection::begin()':                                                                                                        
/root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:132: undefined reference to `PQexec'                                                                                               
/usr/bin/ld: /root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:133: undefined reference to `PQclear'             
/usr/bin/ld: transactions/pgsql/DBConnection.o: in function `CDBConnection::connect()':                                                                                                      
/root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:139: undefined reference to `PQconnectdb'
/usr/bin/ld: transactions/pgsql/DBConnection.o: in function `CDBConnection::commit()':                                                                                                       
/root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:145: undefined reference to `PQexec'                                                                                               
/usr/bin/ld: /root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:146: undefined reference to `PQclear'
/usr/bin/ld: transactions/pgsql/DBConnection.o: in function `CDBConnection::escape(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
/root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:152: undefined reference to `PQescapeLiteral'     
/usr/bin/ld: transactions/pgsql/DBConnection.o: in function `CDBConnection::disconnect()':                                                                                                   
/root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:161: undefined reference to `PQfinish'            
/usr/bin/ld: transactions/pgsql/DBConnection.o: in function `CDBConnection::exec(char const*, int, unsigned int const*, char const* const*, int const*, int const*, int)':                   
/root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:176: undefined reference to `PQexecParams'                                                                                         
/usr/bin/ld: /root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:178: undefined reference to `PQresultStatus'
/usr/bin/ld: /root/egen/prj/../src/transactions/pgsql/DBConnection.cpp:194: undefined reference to `PQresultErrorMessage'
markwkm commented 7 months ago

I'm not sure what to make of this. I can reproduce it on debian, but ld doesn't complain on RHEL, Rocky, CentOS, Ubuntu, or Void. clang's toolchain doesn't seem to do this. It seems to finish compiling successfully on debian with clang. (e.g. CXX=/usr/bin/clang++ dbt5 build-egen egendir)

But I haven't tried running the binaries yet after compiling with clang...

karim-manaouil commented 7 months ago

Ok, thanks for taking a look. I'll try out clang and see where it goes.

karim-manaouil commented 7 months ago

@markwkm It compiled with clang++, but the post processing scripts are broken. After the running the benchmark with

dbt5 run --tpcetools=/mnt/egen -s 250 -d 600 -u 1000 pgsql /tmp/results

I opened /tmp/results/summary.rst. It was all zeroes. I opened /tmp/results/post-process.log and I got this log

Error: in prepare, near ")": syntax error
  SELECT ( - ) / 60.0;
             ^--- error here
Parse error near line 1: near ";": syntax error
  SELECT count(time) FROM mix WHERE time > ;
                             error here ---^
Parse error near line 1: near ",": syntax error
   , count(time)      , 100.0 * count(time) /       , min(response)      , avg(r
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  T txn      , count(time) FROM mix WHERE time >    AND time <    AND code = 1 G
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  T txn      , count(time) FROM mix WHERE time >    AND time <    AND code < 0 G
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  T txn      , count(time) FROM mix WHERE time >    AND time <    AND code > 1 G
                                      error here ---^
/usr/local/bin/dbt5-post-process: 224: printf: N/A: expected numeric value
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '1'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '2'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '8'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '3'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '0'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '5'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '6'   AND time >    AND time <  ORDER BY respons
Error: in prepare, near ")": syntax error
  SELECT ( - ) / 60.0;
             ^--- error here
Parse error near line 1: near ";": syntax error
  SELECT count(time) FROM mix WHERE time > ;
                             error here ---^
Parse error near line 1: near ",": syntax error
   , count(time)      , 100.0 * count(time) /       , min(response)      , avg(r
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  T txn      , count(time) FROM mix WHERE time >    AND time <    AND code = 1 G
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  T txn      , count(time) FROM mix WHERE time >    AND time <    AND code < 0 G
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  T txn      , count(time) FROM mix WHERE time >    AND time <    AND code > 1 G
                                      error here ---^
/usr/local/bin/dbt5-post-process: 224: printf: N/A: expected numeric value
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '1'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '2'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '8'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '3'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '0'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '5'   AND time >    AND time <  ORDER BY respons
                                      error here ---^
Parse error near line 1: near "AND": syntax error
  response FROM mix WHERE txn = '6'   AND time >    AND time <  ORDER BY respons

Is there a chance this can be fixed?

Note: I'm running SQLite version 3.40.1 2022-12-28 14:03:47

karim-manaouil commented 7 months ago

@markwkm I did some debugging. The issue comes from dbt5-post-process line 149 ($STARTTIME variable).

The database is created correctly, data is loaded from the driver and me directories, and the indexes are also created fine, etc (I checked this by keeping the database around and manually connecting via sqlite3 over the command line).

The issue is the query that initialises $STARTTIME returns an empty string.

sqlite> SELECT max(time) from mix where txn='START';

sqlite> 

This line is read from CSV files and it's written by Driver.cpp (line 236) at the end of the ram-up to indicate the start of the real benchmark results.

I grepped the CSV files at results/driver and results/me. None of them contains the string START, which means it's never written by Driver.cpp, in the first place. Now why is that? Is it possibly because of clang++ optimising out something?

Edit: fixed typos

markwkm commented 7 months ago

Many of the scripts are not tolerant of bad data. For example it's hard to say whether it's bad because not every transaction ran, and there can be a number of reasons for that. (e.g. run duration too short, brokerage house didn't connect to the database...)

If you can upload the entire results directory somewhere, I can try to see if it's obvious to me what happened.

I still haven't made time yet to try the binaries myself on Debian + clang...

markwkm commented 7 months ago

I just tried this on Ubuntu 22.04, where I also used clang++ to avoid those linker errors, and seems to work for me using default database build parameters:

==========================================  ==================================
Reported Throughput:           12.00 trtps  Configured Customers:         5000
==========================================  ==================================

==================  ==========  ==========  ==========  ==========
Response Times (s)     Minimum     Average  90th %tile     Maximum
==================  ==========  ==========  ==========  ==========
     Broker Volume        0.00        0.00        0.00        0.00
 Customer Position        0.00        0.01        0.04        0.09
       Market Feed        0.03        0.03        0.03        0.03
      Market Watch        0.01        0.10        0.20        0.21
   Security Detail        0.00        0.01        0.01        0.03
      Trade Lookup        0.02        3.20       11.08       13.83
       Trade Order        0.00        0.01        0.01        0.04
      Trade Result        0.00        0.01        0.03        0.07
      Trade Status        0.01        0.03        0.04        0.09
      Trade Update        0.03        2.06       10.68       10.68
  Data Maintenance        0.00        0.01         N/A        0.01
==================  ==========  ==========  ==========  ==========

==================  ==========  ==========  ==========  ==========  ==========
   Transaction Mix   Txn Count   Mix %tile  Rollbacks     Warnings     Invalid
==================  ==========  ==========  ==========  ==========  ==========
     Broker Volume          12       3.614           0           0           0
 Customer Position          38      11.446           0           0           0
       Market Feed           2       0.602           0           0           0
      Market Watch          62      18.675           0           0           0
   Security Detail          53      15.964           0           0           0
      Trade Lookup          28       8.434           0           0           0
       Trade Order          26       7.831           0           0           0
      Trade Result          24       7.229           0           0           0
      Trade Status          71      21.386           0           0           0
      Trade Update          10       3.012           0           0           0
  Data Maintenance           2         N/A           0           0           0
==================  ==========  ==========  ==========  ==========  ==========

==================================================================  ==========
Test Duration and Timings
==================================================================  ==========
                                            Ramp-up Time (minutes)         0.0
                                    Measurement Interval (minutes)         2.0
    Total Number of Transactions Completed in Measurement Interval         332
==================================================================  ==========
markwkm commented 3 months ago

I think I figured this out. It's because of the order of linker flags. I have a patch baking to use the LIBS env var instead of LDFALGS.

diff --git a/scripts/dbt5-build-egen.in b/scripts/dbt5-build-egen.in
index 9427e3b4..3ef2d65d 100755
--- a/scripts/dbt5-build-egen.in
+++ b/scripts/dbt5-build-egen.in
@@ -151,6 +151,7 @@ fi
 (cd "${EGENDIR}/prj" && \
        make -f Makefile clean && \
        CCFLAGS="-Wall -D__unix -g -std=c++98 -ansi -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -D_LARGEFILE64_SOURCE -DCOMPILE_CUSTOM_LOAD -DPGSQL -I${EGENDIR}/inc ${INCLUDEDIR} -I${EGENDIR}/Utilities/inc ${EXTRAINCLUDE}" \
-       LDFLAGS="-lpthread -lpq ${EXTRALDDIR}" \
+     LDFLAGS="${EXTRALDDIR}" \
+     LIBS="-lpthread -lpq" \
        make -j$(nproc) -f Makefile) \
        || (echo "ERROR: cannot build egen" && exit 1)   
markwkm commented 3 months ago

Hopefully now fixed in https://github.com/osdldbt/dbt5/commit/e7015d6a215ba2b994c97f166e3c064b0f3dea01. Released in v0.10.1.