[MCOL-1154] mcsapi causes data corruption if a NUL termination is sent with a string Created: 2018-01-10  Updated: 2023-10-26  Resolved: 2018-01-15

Status: Closed
Project: MariaDB ColumnStore
Component/s: None
Affects Version/s: None
Fix Version/s: Icebox

Type: Bug Priority: Major
Reporter: Andrew Hutchings (Inactive) Assignee: Andrew Hutchings (Inactive)
Resolution: Not a Bug Votes: 0
Labels: None

Issue Links:
Relates
relates to MCOL-1160 Bulk write API doesn't start new bloc... Closed
Sprint: 2018-01, 2018-02

 Description   

The following example will cause corruption due to the extra NULs at the end of the first string:

#include <libmcsapi/mcsapi.h>
#include <iostream>
 
int main(void)
{
    mcsapi::ColumnStoreDriver* driver = nullptr;
    mcsapi::ColumnStoreBulkInsert* bulk = nullptr;
    try {
        driver = new mcsapi::ColumnStoreDriver();
        bulk = driver->createBulkInsert("test", "t1", 0, 0);
        bulk->setColumn(0, 1);
	std::string str("hello world1");
	str.resize(14);
        bulk->setColumn(1, str);
        bulk->writeRow();
        bulk->setColumn(0, 2);
        bulk->setColumn(1, "hello world4");
        bulk->writeRow();
        bulk->setColumn(0, 3);
        bulk->setColumn(1, "hello world9");
        bulk->writeRow();
        bulk->setColumn(0, 4);
        bulk->setColumn(1, "hello world16");
        bulk->writeRow();
        bulk->commit();
    } catch (mcsapi::ColumnStoreError &e) {
        std::cout << "Error caught: " << e.what() << std::endl;
    }
    delete bulk;
    delete driver;
}



 Comments   
Comment by Andrew Hutchings (Inactive) [ 2018-01-11 ]

Patch trims off trailing NULs from VARCHAR/CHAR/TEXT data.

For QA: test mcol1154 included in regression suite

Comment by Jens Röwekamp (Inactive) [ 2018-01-12 ]

Can't reproduce the bug on Ubuntu 16.04 and CentOS 7.

Locally copied test/mcol-1154.cpp and test/CMakeLists.txt from branch MCOL-1154 to branches master and develop-1.1.
Compiled and installed branch master with flag TEST_RUNNER=ON and ran make check. All 16 tests including mcol-1154 passed.
Compiled and installed branch develop-1.1 with flag TEST_RUNNER=ON and ran make check. All 16 tests including mcol-1154 passed.
Compiled and installed branch MCOL-1154 with flag TEST_RUNNER=ON and ran make check. All 16 tests including mcol-1154 passed.

More information about failing OS or bug needed. Maybe test case needs to be adapted to show the actual bug.

Comment by Andrew Hutchings (Inactive) [ 2018-01-15 ]

Fixed the test, only worked if table was already created and had been queried due to caches.

Comment by Andrew Hutchings (Inactive) [ 2018-01-15 ]

And now the fix doesn't work...

Comment by Andrew Hutchings (Inactive) [ 2018-01-15 ]

Root cause is completely wrong, abandoning this one and opening a new bug.

Comment by Andrew Hutchings (Inactive) [ 2018-01-15 ]

Will open a new bug with the real problem

Generated at Thu Feb 08 02:26:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.