Skip to content

BE crash when closing OlapTableSink #1506

@morningman

Description

@morningman

Describe the bug

Status OlapTableSink::close(RuntimeState* state, Status close_status) {
    SCOPED_TIMER(_profile->total_time_counter());
    Status status = close_status;
    if (status.ok()) {
        {
            SCOPED_TIMER(_close_timer);
            for (auto channel : _channels) {
                status = channel->close(state);
                if (!status.ok()) {
                    LOG(WARNING) << "close channel failed, load_id=" << _load_id
                        << ", txn_id=" << _txn_id;
                }
            }
        }
        COUNTER_SET(_input_rows_counter, _number_input_rows);
        COUNTER_SET(_output_rows_counter, _number_output_rows);
        COUNTER_SET(_filtered_rows_counter, _number_filtered_rows);
        COUNTER_SET(_send_data_timer, _send_data_ns);
        COUNTER_SET(_convert_batch_timer, _convert_batch_ns);
        COUNTER_SET(_validate_data_timer, _validate_data_ns);
        COUNTER_SET(_wait_in_flight_packet_timer, _wait_in_flight_packet_ns);
        COUNTER_SET(_serialize_batch_timer, _serialize_batch_ns);

        state->update_num_rows_load_filtered(_number_filtered_rows);
    } else {
        for (auto channel : _channels) {
            channel->cancel();
        }
    }
    Expr::close(_output_expr_ctxs, state);
    _output_batch.reset();
    return status;
}

BE may crash when executing SCOPED_TIMER(_profile->total_time_counter());

Because is the OlapTableSink is not prepared before calling close(), the _profile is not initialized, so it will access illegal memory.

Metadata

Metadata

Assignees

Labels

kind/fixCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions