[ 
https://issues.apache.org/jira/browse/KUDU-2428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16466197#comment-16466197
 ] 

Todd Lipcon commented on KUDU-2428:
-----------------------------------

Note the docs for the lower and upper bound parameters for add_range_partition:

{code}
  /// @param [in] lower_bound
  ///   Row to use as a lower bound. The KuduTableCreator instance takes
  ///   ownership of this parameter. If row is empty, no lower bound is imposed
  ///   on the table range. If a column of the @c lower_bound row is missing
  ///   a value, the logical minimum value for that column type is used as the
  ///   default.
  /// @param [in] upper_bound
  ///   Row to use as an upper bound. The KuduTableCreator instance takes
  ///   ownership of this parameter. If row is empty, no upper bound is imposed
  ///   on the table range. If a column of the @c upper_bound row is missing
  ///   a value, the logical maximum value for that column type is used as the
  ///   default.
{code}

In particular, *the KuduTableCreator instance takes ownership of this 
parameter*. In your example, you're passing 'row2' and 'row3' twice to the 
TableCreator, so they are getting double-deleted.

I suppose the docs aren't completely clear here that you can't pass the same 
row instance twice, but typically "takes ownership" implies that you aren't 
allowed to use the instance after passing it to the function.

> Segmentation fault when calling add_range_partition multiple times
> ------------------------------------------------------------------
>
>                 Key: KUDU-2428
>                 URL: https://issues.apache.org/jira/browse/KUDU-2428
>             Project: Kudu
>          Issue Type: Bug
>          Components: client
>    Affects Versions: 1.7.0
>            Reporter: Mike Feng
>            Priority: Blocker
>             Fix For: Backlog
>
>
> Hi,
> I'm trying to modify and run the following sample.cc program to create a 
> table with multiple range partitions via multiple calls to 
> add_range_partition() and the program got a Segmentation fault. 
> On the other hand, if I call add_range_partition() once and the program runs 
> fine.  
> So I'm wondering if calling add_range_partition() multiple times for a single 
> table is supported or not?  This makes it useful when trying to partition the 
> range on multiple primary key columns, e.g. on (key, int_val).
> Thanks.
>  
> Modified only the following function in 
> $HOME/kudu/src/kudu/client/samples/sample.cc
> {code}
> static Status CreateTable(const shared_ptr<KuduClient>& client,
>  const string& table_name,
>  const KuduSchema& schema,
>  int num_tablets) {
> KuduPartialRow* row = schema.NewRow();
>  KUDU_CHECK_OK(row->SetInt32("key", 100));
> KuduPartialRow* row2 = schema.NewRow();
>  KUDU_CHECK_OK(row2->SetInt32("key", 100));
> KuduPartialRow* row3 = schema.NewRow();
>  KUDU_CHECK_OK(row3->SetInt32("key", 200));
> KuduPartialRow* row4 = schema.NewRow();
>  KUDU_CHECK_OK(row4->SetInt32("key", 200));
> vector<string> column_names;
>  column_names.push_back("key");
> // Create the table.
>  KuduTableCreator* table_creator = client->NewTableCreator();
>  table_creator->add_range_partition(row, row2);
>  table_creator->add_range_partition(row2, row3);
>  table_creator->add_range_partition(row3, row4);
>  Status s = table_creator->table_name(table_name)
>  .schema(&schema)
>  .set_range_partition_columns(column_names)
> .set_engine_name(DEFAULT_ENGINE_NAME)
>  .num_replicas(1)
>  .Create();
>  delete table_creator;
>  return s;
> }
> {code}
>  
> Running it fails as follows:
> $ ./sample 127.0.0.1
> Segmentation fault (core dumped)
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to