Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-1662

WriteEngine bulk methods do not version dictionaries correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.1.5, 1.2.1
    • Fix Version/s: 1.1.7, 1.2.3
    • Component/s: mcsapi
    • Labels:
      None
    • Environment:
      single node docker image
    • Sprint:
      2018-16, 2018-17, 2018-18, 2018-19, 2018-20, 2018-21

      Description

      The following test case creates a table, inserts a row into it via mcsapi and updates it after the bulk load has committed.

      #include <iostream>
      #include <string>
      #include <sstream>
       
      #include <mysql.h>
      #include <libmcsapi/mcsapi.h>
       
      #include <boost/property_tree/ptree.hpp>
      #include <boost/property_tree/xml_parser.hpp>
      namespace pt = boost::property_tree;
       
      int main(int argc, char** argv)
      {
          if (argc != 3)
          {
              std::cout << "Usage: DATABASE TABLE" << std::endl
                        << "Columnstore.xml must be located in /usr/local/mariadb/columnstore/etc/Columnstore.xml" << std::endl;
              return 1;
          }
       
          // Read the credentials from the Columnstore.xml
          pt::ptree tree;
          pt::read_xml("/usr/local/mariadb/columnstore/etc/Columnstore.xml", tree);
          std::string host = tree.get<std::string>("Columnstore.CrossEngineSupport.Host");
          int port = tree.get<int>("Columnstore.CrossEngineSupport.Port");
          std::string user = tree.get<std::string>("Columnstore.CrossEngineSupport.User");
          std::string password = tree.get<std::string>("Columnstore.CrossEngineSupport.Password");
          std::string database = argv[1];
          std::string table = argv[2];
       
          // Connect to CS and create the table
          auto mysql =  mysql_init(nullptr);
          mysql_real_connect(mysql, host.c_str(), user.c_str(),
                             password.empty() ? NULL : password.c_str(),
                             NULL, port, NULL, 0);
       
          std::stringstream query;
          query << "CREATE TABLE " << database << "." << table << "(id int, data varchar(200)) ENGINE=Columnstore";
          mysql_query(mysql, query.str().c_str());
       
          // Connect with mcsapi and insert one row with a bulk insert
          auto driver = new mcsapi::ColumnStoreDriver(cnf);
          auto bulk = driver->createBulkInsert(database, table, 0, 0);
          auto info = driver->getSystemCatalog().getTable(database, table);
          uint32_t pos1 = info.getColumn("id").getPosition();
          uint32_t pos2 = info.getColumn("data").getPosition();
          bulk->setColumn(pos1, 1);
          bulk->setColumn(pos2, "hello");
          bulk->writeRow();
          bulk->commit();
       
          // Update the row we just inserted
          std::stringstream query;
          query << "UPDATE `" << database << "`.`" << table << "` SET `id` = 1, `data` = 'Hello' WHERE `id` = 1 AND `data` = 'hello'";
          mysql_query(mysql, query.str().c_str());
       
          return 0;
      }
      

      Once the update is done, the data in the table is corrupted:

      MariaDB [test]> select * from test.t1;
      +------+----------+
      | id   | data     |
      +------+----------+
      |    1 | _CpNoTf_ |
      +------+----------+
      1 row in set (0.05 sec)
      

      Manually updating it afterwards doesn't fix it, it still remains invalid:

      MariaDB [test]> update test.t1 set data = "Hello" where id = 1;
      Query OK, 1 row affected (0.15 sec)
      Rows matched: 0  Changed: 0  Warnings: 0
       
      MariaDB [test]> select * from test.t1;
      +------+----------+
      | id   | data     |
      +------+----------+
      |    1 | _CpNoTf_ |
      +------+----------+
      1 row in set (0.02 sec)
      

      Additional note from Andrew: This also happens when using INSERT...SELECT and LDI when cpimport mode is not used.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pleblanc Patrick LeBlanc (Inactive)
              Reporter:
              markus makela markus makela
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration