Skip to content

Commit

Permalink
Merge branch 'master' into support_json_contains_path
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaRise authored Dec 13, 2023
2 parents c675663 + 5417d84 commit 450e9c7
Show file tree
Hide file tree
Showing 62 changed files with 1,127 additions and 539 deletions.
2 changes: 1 addition & 1 deletion contrib/poco
51 changes: 14 additions & 37 deletions dbms/cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This strings autochanged from release_lib.sh:
set(VERSION_DESCRIBE v1.1.54381-testing)
set(VERSION_REVISION 54381)
set(VERSION_GITHASH af82c78a45b6a6f136e10bb2e7ca9b936d09a46c)
# end of autochange

set (VERSION_MAJOR 1)
set (VERSION_MINOR 1)
set (VERSION_PATCH ${VERSION_REVISION})
set (VERSION_EXTRA "")
set (VERSION_TWEAK "")

set (VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
if (VERSION_TWEAK)
set(VERSION_STRING "${VERSION_STRING}.${VERSION_TWEAK}")
endif ()
if (VERSION_EXTRA)
set(VERSION_STRING "${VERSION_STRING}${VERSION_EXTRA}")
endif ()

set (VERSION_FULL "${PROJECT_NAME} ${VERSION_STRING}")

if (OS_DARWIN)
# dirty hack: ld: malformed 64-bit a.b.c.d.e version number: 1.1.54160
math (EXPR VERSION_SO1 "${VERSION_REVISION}/255")
math (EXPR VERSION_SO2 "${VERSION_REVISION}%255")
set (VERSION_SO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_SO1}.${VERSION_SO2}")
else ()
set (VERSION_SO "${VERSION_STRING}")
endif ()

set (TIFLASH_NAME "TiFlash")

# Semantic version.
set (TIFLASH_VERSION_MAJOR 4)
set (TIFLASH_VERSION_MINOR 1)
set (TIFLASH_VERSION_REVISION 0)
set (TIFLASH_VERSION "${TIFLASH_VERSION_MAJOR}.${TIFLASH_VERSION_MINOR}.${TIFLASH_VERSION_REVISION}")

# Release version that follows PD/TiKV/TiDB convention.
# Variables bellow are important, use `COMMAND_ERROR_IS_FATAL ANY`(since cmake 3.19) to confirm that there is output.

Expand All @@ -63,6 +26,20 @@ execute_process(
COMMAND_ERROR_IS_FATAL ANY
)

# Extract the major version number
string(REGEX REPLACE "^v([0-9]+).*" "\\1" TIFLASH_VERSION_MAJOR ${TIFLASH_RELEASE_VERSION})
# Extract the minor version number
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" TIFLASH_VERSION_MINOR ${TIFLASH_RELEASE_VERSION})
# Extract the patch version number
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" TIFLASH_VERSION_PATCH ${TIFLASH_RELEASE_VERSION})
# Extract the extra information if it exists
if (${TIFLASH_RELEASE_VERSION} MATCHES "-.*")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+-(.*)$" "\\1" TIFLASH_VERSION_EXTRA ${TIFLASH_RELEASE_VERSION})
set(TIFLASH_VERSION "${TIFLASH_VERSION_MAJOR}.${TIFLASH_VERSION_MINOR}.${TIFLASH_VERSION_PATCH}-${TIFLASH_VERSION_EXTRA}")
else ()
set(TIFLASH_VERSION "${TIFLASH_VERSION_MAJOR}.${TIFLASH_VERSION_MINOR}.${TIFLASH_VERSION_PATCH}")
endif ()

set (TIFLASH_EDITION $ENV{TIFLASH_EDITION})
if (NOT TIFLASH_EDITION)
set (TIFLASH_EDITION Community)
Expand Down
45 changes: 18 additions & 27 deletions dbms/src/Client/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

#include <Client/Connection.h>
#include <Client/TimeoutSetter.h>
#include <Common/ClickHouseRevision.h>
#include <Common/CurrentMetrics.h>
#include <Common/Exception.h>
#include <Common/FmtUtils.h>
#include <Common/NetException.h>
#include <Common/TiFlashBuildInfo.h>
#include <Common/config.h>
#include <Core/Defines.h>
#include <DataStreams/NativeBlockInputStream.h>
Expand All @@ -44,7 +44,6 @@ namespace ErrorCodes
{
extern const int NETWORK_ERROR;
extern const int SOCKET_TIMEOUT;
extern const int SERVER_REVISION_IS_TOO_OLD;
extern const int UNEXPECTED_PACKET_FROM_SERVER;
extern const int UNKNOWN_PACKET_FROM_SERVER;
extern const int SUPPORT_IS_DISABLED;
Expand Down Expand Up @@ -98,7 +97,7 @@ void Connection::connect()
server_name,
server_version_major,
server_version_minor,
server_revision);
server_version_patch);
}
catch (Poco::Net::NetException & e)
{
Expand Down Expand Up @@ -131,10 +130,10 @@ void Connection::disconnect()
void Connection::sendHello()
{
writeVarUInt(Protocol::Client::Hello, *out);
writeStringBinary((DBMS_NAME " ") + client_name, *out);
writeVarUInt(DBMS_VERSION_MAJOR, *out);
writeVarUInt(DBMS_VERSION_MINOR, *out);
writeVarUInt(ClickHouseRevision::get(), *out);
writeStringBinary(fmt::format("{} {}", TiFlashBuildInfo::getName(), client_name), *out);
writeVarUInt(TiFlashBuildInfo::getMajorVersion(), *out);
writeVarUInt(TiFlashBuildInfo::getMinorVersion(), *out);
writeVarUInt(TiFlashBuildInfo::getPatchVersion(), *out);
writeStringBinary(default_database, *out);
writeStringBinary(user, *out);
writeStringBinary(password, *out);
Expand All @@ -154,15 +153,9 @@ void Connection::receiveHello()
readStringBinary(server_name, *in);
readVarUInt(server_version_major, *in);
readVarUInt(server_version_minor, *in);
readVarUInt(server_revision, *in);
if (server_revision >= DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE)
{
readStringBinary(server_timezone, *in);
}
if (server_revision >= DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME)
{
readStringBinary(server_display_name, *in);
}
readVarUInt(server_version_patch, *in);
readStringBinary(server_timezone, *in);
readStringBinary(server_display_name, *in);
}
else if (packet_type == Protocol::Server::Exception)
receiveException()->rethrow();
Expand Down Expand Up @@ -199,15 +192,15 @@ UInt16 Connection::getPort() const
return port;
}

void Connection::getServerVersion(String & name, UInt64 & version_major, UInt64 & version_minor, UInt64 & revision)
void Connection::getServerVersion(String & name, UInt64 & version_major, UInt64 & version_minor, UInt64 & version_patch)
{
if (!connected)
connect();

name = server_name;
version_major = server_version_major;
version_minor = server_version_minor;
revision = server_revision;
version_patch = server_version_patch;
}

const String & Connection::getServerTimezone()
Expand Down Expand Up @@ -284,7 +277,7 @@ TablesStatusResponse Connection::getTablesStatus(const TablesStatusRequest & req
TimeoutSetter timeout_setter(*socket, sync_request_timeout, true);

writeVarUInt(Protocol::Client::TablesStatusRequest, *out);
request.write(*out, server_revision);
request.write(*out);
out->next();

UInt64 response_type = 0;
Expand All @@ -296,7 +289,7 @@ TablesStatusResponse Connection::getTablesStatus(const TablesStatusRequest & req
throwUnexpectedPacket(response_type, "TablesStatusResponse");

TablesStatusResponse response;
response.read(*in, server_revision);
response.read(*in);
return response;
}

Expand All @@ -320,7 +313,6 @@ void Connection::sendQuery(
writeStringBinary(query_id, *out);

/// Client info.
if (server_revision >= DBMS_MIN_REVISION_WITH_CLIENT_INFO)
{
ClientInfo client_info_to_send;

Expand All @@ -329,7 +321,7 @@ void Connection::sendQuery(
/// No client info passed - means this query initiated by me.
client_info_to_send.query_kind = ClientInfo::QueryKind::INITIAL_QUERY;
client_info_to_send.fillOSUserHostNameAndVersionInfo();
client_info_to_send.client_name = (DBMS_NAME " ") + client_name;
client_info_to_send.client_name = fmt::format("{} {}", TiFlashBuildInfo::getName(), client_name);
}
else
{
Expand All @@ -338,7 +330,7 @@ void Connection::sendQuery(
client_info_to_send.query_kind = ClientInfo::QueryKind::SECONDARY_QUERY;
}

client_info_to_send.write(*out, server_revision);
client_info_to_send.write(*out);
}

/// Per query settings.
Expand Down Expand Up @@ -382,8 +374,7 @@ void Connection::sendData(const Block & block, const String & name)
else
maybe_compressed_out = out;

block_out
= std::make_shared<NativeBlockOutputStream>(*maybe_compressed_out, server_revision, block.cloneEmpty());
block_out = std::make_shared<NativeBlockOutputStream>(*maybe_compressed_out, 1, block.cloneEmpty());
}

writeVarUInt(Protocol::Client::Data, *out);
Expand Down Expand Up @@ -567,7 +558,7 @@ void Connection::initBlockInput()
else
maybe_compressed_in = in;

block_in = std::make_shared<NativeBlockInputStream>(*maybe_compressed_in, server_revision);
block_in = std::make_shared<NativeBlockInputStream>(*maybe_compressed_in, 1);
}
}

Expand All @@ -593,7 +584,7 @@ std::unique_ptr<Exception> Connection::receiveException()
Progress Connection::receiveProgress()
{
Progress progress;
progress.read(*in, server_revision);
progress.read(*in);
return progress;
}

Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Client/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Connection : private boost::noncopyable
/// Change default database. Changes will take effect on next reconnect.
void setDefaultDatabase(const String & database);

void getServerVersion(String & name, UInt64 & version_major, UInt64 & version_minor, UInt64 & revision);
void getServerVersion(String & name, UInt64 & version_major, UInt64 & version_minor, UInt64 & version_patch);

const String & getServerTimezone();
const String & getServerDisplayName();
Expand Down Expand Up @@ -231,7 +231,7 @@ class Connection : private boost::noncopyable
String server_name;
UInt64 server_version_major = 0;
UInt64 server_version_minor = 0;
UInt64 server_revision = 0;
UInt64 server_version_patch = 0;
String server_timezone;
String server_display_name;

Expand Down
18 changes: 11 additions & 7 deletions dbms/src/Client/ConnectionPoolWithFailover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ IConnectionPool::Entry ConnectionPoolWithFailover::getImpl(
};

GetPriorityFunc get_priority;
switch (settings ? LoadBalancing(settings->load_balancing) : default_load_balancing)
switch (settings ? static_cast<LoadBalancing>(settings->load_balancing) : default_load_balancing)
{
case LoadBalancing::NEAREST_HOSTNAME:
get_priority = [&](size_t i) {
Expand Down Expand Up @@ -126,7 +126,7 @@ std::vector<ConnectionPoolWithFailover::TryResult> ConnectionPoolWithFailover::g
throw DB::Exception("Unknown pool allocation mode", DB::ErrorCodes::LOGICAL_ERROR);

GetPriorityFunc get_priority;
switch (settings ? LoadBalancing(settings->load_balancing) : default_load_balancing)
switch (settings ? static_cast<LoadBalancing>(settings->load_balancing) : default_load_balancing)
{
case LoadBalancing::NEAREST_HOSTNAME:
get_priority = [&](size_t i) {
Expand Down Expand Up @@ -162,11 +162,12 @@ ConnectionPoolWithFailover::TryResult ConnectionPoolWithFailover::tryGetEntry(
String server_name;
UInt64 server_version_major;
UInt64 server_version_minor;
UInt64 server_revision;
UInt64 server_version_patch;
if (table_to_check)
result.entry->getServerVersion(server_name, server_version_major, server_version_minor, server_revision);
result.entry
->getServerVersion(server_name, server_version_major, server_version_minor, server_version_patch);

if (!table_to_check || server_revision < DBMS_MIN_REVISION_WITH_TABLES_STATUS)
if (!table_to_check)
{
result.entry->forceConnected();
result.is_usable = true;
Expand All @@ -183,8 +184,11 @@ ConnectionPoolWithFailover::TryResult ConnectionPoolWithFailover::tryGetEntry(
auto table_status_it = status_response.table_states_by_id.find(*table_to_check);
if (table_status_it == status_response.table_states_by_id.end())
{
fail_message = "There is no table " + table_to_check->database + "." + table_to_check->table
+ " on server: " + result.entry->getDescription();
fail_message = fmt::format(
"There is no table {}.{} on server: {}",
table_to_check->database,
table_to_check->table,
result.entry->getDescription());
LOG_WARNING(log, fail_message);

return result;
Expand Down
23 changes: 0 additions & 23 deletions dbms/src/Common/ClickHouseRevision.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions dbms/src/Common/ClickHouseRevision.h

This file was deleted.

2 changes: 1 addition & 1 deletion dbms/src/Common/ErrorCodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ extern const int WRONG_PASSWORD = 193;
extern const int REQUIRED_PASSWORD = 194;
extern const int IP_ADDRESS_NOT_ALLOWED = 195;
extern const int UNKNOWN_ADDRESS_PATTERN_TYPE = 196;
extern const int SERVER_REVISION_IS_TOO_OLD = 197;
// extern const int SERVER_REVISION_IS_TOO_OLD = 197; // Not Used anymore
extern const int DNS_ERROR = 198;
extern const int UNKNOWN_QUOTA = 199;
extern const int QUOTA_DOESNT_ALLOW_KEYS = 200;
Expand Down
3 changes: 2 additions & 1 deletion dbms/src/Common/FailPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ namespace DB
M(force_set_parallel_prehandle_threshold) \
M(force_raise_prehandle_exception) \
M(force_agg_on_partial_block) \
M(delta_tree_create_node_fail)
M(delta_tree_create_node_fail) \
M(disable_flush_cache)

#define APPLY_FOR_PAUSEABLE_FAILPOINTS_ONCE(M) \
M(pause_with_alter_locks_acquired) \
Expand Down
Loading

0 comments on commit 450e9c7

Please sign in to comment.