Coverage Report

Created: 2026-03-12 17:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/agent/be_exec_version_manager.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "agent/be_exec_version_manager.h"
19
20
#include "common/exception.h"
21
22
namespace doris {
23
24
27.2M
Status BeExecVersionManager::check_be_exec_version(int be_exec_version) {
25
27.2M
    if (be_exec_version > max_be_exec_version || be_exec_version < min_be_exec_version) {
26
0
        return Status::InternalError(
27
0
                "Received be_exec_version is not supported, be_exec_version={}, "
28
0
                "min_be_exec_version={}, max_be_exec_version={}, maybe due to FE version not "
29
0
                "match with BE.",
30
0
                be_exec_version, min_be_exec_version, max_be_exec_version);
31
0
    }
32
27.2M
    return Status::OK();
33
27.2M
}
34
35
int BeExecVersionManager::get_function_compatibility(int be_exec_version,
36
519k
                                                     std::string function_name) {
37
519k
    if (_function_restrict_map.contains(function_name) && be_exec_version != get_newest_version()) {
38
0
        throw Exception(Status::InternalError(
39
0
                "function {} do not support old be exec version, maybe it's because doris are "
40
0
                "doing a rolling upgrade. newest_version={}, input_be_exec_version={}",
41
0
                function_name, get_newest_version(), be_exec_version));
42
0
    }
43
44
519k
    auto it = _function_change_map.find(function_name);
45
519k
    if (it == _function_change_map.end()) {
46
        // 0 means no compatibility issues need to be dealt with
47
519k
        return 0;
48
519k
    }
49
50
18.4E
    auto version_it = it->second.lower_bound(be_exec_version);
51
18.4E
    if (version_it == it->second.end()) {
52
0
        return 0;
53
0
    }
54
55
18.4E
    return *version_it;
56
18.4E
}
57
58
void BeExecVersionManager::check_function_compatibility(int current_be_exec_version,
59
                                                        int data_be_exec_version,
60
2.26k
                                                        std::string function_name) {
61
2.26k
    if (get_function_compatibility(current_be_exec_version, function_name) ==
62
2.26k
        get_function_compatibility(data_be_exec_version, function_name)) {
63
2.26k
        return;
64
2.26k
    }
65
66
3
    throw Exception(Status::InternalError(
67
3
            "agg state data with {} is not supported, "
68
3
            "current_be_exec_version={}, data_be_exec_version={}, need to rebuild the data "
69
3
            "or set the be_exec_version={} in fe.conf temporary",
70
3
            function_name, current_be_exec_version, data_be_exec_version, data_be_exec_version));
71
2.26k
}
72
73
/**
74
 * When we have some breaking change for execute engine, we should update be_exec_version.
75
 * NOTICE: The change could only be dont in X.Y.0 version. and if you introduced new version number N,
76
 *  remember remove version N-1's all REUSEABLE changes in master branch only. REUSEABLE means scalar or agg functions' replacement.
77
 *  If not, the old replacement will happens in the new version which is wrong.
78
 *
79
 * 0: not contain be_exec_version.
80
 * 1: start from doris 1.2.0
81
 *    a. remove ColumnString terminating zero.
82
 *    b. runtime filter use new hash method.
83
 * 2: start from doris 2.0.0
84
 *    a. function month/day/hour/minute/second's return type is changed to smaller type.
85
 *    b. in order to solve agg of sum/count is not compatibility during the upgrade process
86
 *    c. change the string hash method in runtime filter
87
 *    d. elt function return type change to nullable(string)
88
 *    e. add repeat_max_num in repeat function
89
 * 3: start from doris 2.0.0 (by some mistakes)
90
 *    a. aggregation function do not serialize bitmap to string.
91
 *    b. support window funnel mode.
92
 * 4: start from doris 2.1.0
93
 *    a. ignore this line, window funnel mode should be enabled from 2.0.
94
 *    b. array contains/position/countequal function return nullable in less situations.
95
 *    c. cleared old version of Version 2.
96
 *    d. unix_timestamp function support timestamp with float for datetimev2, and change nullable mode.
97
 *    e. change shuffle serialize/deserialize way 
98
 *    f. shrink some function's nullable mode.
99
 *    g. do local merge of remote runtime filter
100
 *    h. "now": ALWAYS_NOT_NULLABLE -> DEPEND_ON_ARGUMENTS
101
 *
102
 * 5: start from doris 3.0.0
103
 *    a. change some agg function nullable property: PR #37215
104
 *
105
 * 6: start from doris 3.0.1 and 2.1.6
106
 *    a. change the impl of percentile (need fix)
107
 *    b. clear old version of version 3->4
108
 *    c. change FunctionIsIPAddressInRange from AlwaysNotNullable to DependOnArguments
109
 *    d. change variant serde to fix PR #38413
110
 *
111
 * 7: start from doris 3.0.2
112
 *    a. window funnel logic change
113
 *    b. support const column in serialize/deserialize function: PR #41175
114
 */
115
116
// /////////////////////////////////////////////////////////////////////////////
117
// ATTN: !!! BE EXEC VERSION IS A VERY SENSITIVE COMPATIBILITY FIELD !!!
118
// 1. We should avoid abusing be_exec_version, especially not using it to handle
119
//    compatibility issues of functions (use function aliases for that instead).
120
// 2. Do not fork versions in past releases; all new be exec versions should
121
//    first go into master before entering new release versions.
122
// !!! DO NOT CHANGE IT UNLESS YOU ARE 100% SURE WHAT YOU ARE DOING !!!
123
// /////////////////////////////////////////////////////////////////////////////
124
125
// 10: start from doris 4.0.3
126
//   a. use new fixed object serialization way.
127
128
const int BeExecVersionManager::max_be_exec_version = 10;
129
const int BeExecVersionManager::min_be_exec_version = 0;
130
std::map<std::string, std::set<int>> BeExecVersionManager::_function_change_map {};
131
std::set<std::string> BeExecVersionManager::_function_restrict_map;
132
} // namespace doris