Uploaded image for project: 'Kudu'
  1. Kudu
  2. KUDU-1293

Possible deletion-dependency between KuduTableCreator and KuduSchema

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 0.7.0
    • None
    • client
    • Debian Linux Stable

    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);
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            mpilman Markus Pilman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: