Details
Description
I am not very familiar with the Kudu-code, so I can not really point to the problem within the Kudu code. But this is what happens (and is either wrong or should be documented).
I have the following helper function to create schemas:
template<class Fun> void createTable(kudu::client::KuduSession& session, kudu::client::KuduSchemaBuilder& schemaBuilder, const std::string& name, const std::vector<std::string>& rangePartitionColumns, Fun generateSplits) { std::unique_ptr<kudu::client::KuduTableCreator> tableCreator(session.client()->NewTableCreator()); kudu::client::KuduSchema schema; assertOk(schemaBuilder.Build(&schema)); tableCreator->table_name(name); tableCreator->schema(&schema); tableCreator->num_replicas(1); auto splits = generateSplits(schema); // tableCreator->split_rows(splits); assertOk(tableCreator->Create()); }
This code will segfault. The problem seems to be that the KuduTableCreator and KuduSchema need to be destroyed in the correct order. It would be better thow, if there would not be a dependency between these instances. This code works:
template<class Fun> void createTable(kudu::client::KuduSession& session, kudu::client::KuduSchemaBuilder& schemaBuilder, const std::string& name, const std::vector<std::string>& rangePartitionColumns, Fun generateSplits) { std::unique_ptr<kudu::client::KuduTableCreator> tableCreator(session.client()->NewTableCreator()); kudu::client::KuduSchema schema; assertOk(schemaBuilder.Build(&schema)); tableCreator->table_name(name); tableCreator->schema(&schema); tableCreator->num_replicas(1); auto splits = generateSplits(schema); // tableCreator->split_rows(splits); assertOk(tableCreator->Create()); tableCreator.reset(nullptr); }