mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 19:32:07 +00:00
e0d5020a92
- In general, it is expected that clickhouse-*-bridges and clickhouse-server were build from the same source version (e.g. are upgraded "atomically"). If that is not the case, we should at least be able to detect the mismatch and abort. - This commit adds a URL parameter "version", defined in a header shared by the server and bridges. The bridge returns an error in case of mismatch. - The version is *not* send and checked for "ping" requests (used for handshake), only for regular requests send after handshake. This is because the internally thrown server-side exception due to HTTP failure does not propagate the exact HTTP error (it only stores the error as text), and as a result, the server-side handshake code simply retries in case of error with exponential backoff and finally fails with a "timeout error". This is reasonable as pings typically fail due to time out. However, without a rework of HTTP exceptions, version mismatch during ping would also appear as "timeout" which is too misleading. The behavior may be changed later if needed. - Note that introducing a version parameter does not represent a protocol upgrade itself. Bridges older than the server will simply ignore the field. Only servers older than the bridges receive an error but such a situation should never occur in practice.
47 lines
1.6 KiB
C++
47 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <Interpreters/Context.h>
|
|
#include <Server/HTTP/HTTPRequestHandler.h>
|
|
#include <Common/logger_useful.h>
|
|
#include "ExternalDictionaryLibraryHandler.h"
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/// Handler for requests to Library Dictionary Source, returns response in RowBinary format.
|
|
/// When a library dictionary source is created, it sends 'extDict_libNew' request to library bridge (which is started on first
|
|
/// request to it, if it was not yet started). On this request a new sharedLibrayHandler is added to a
|
|
/// sharedLibraryHandlerFactory by a dictionary uuid. With 'extDict_libNew' request come: library_path, library_settings,
|
|
/// names of dictionary attributes, sample block to parse block of null values, block of null values. Everything is
|
|
/// passed in binary format and is urlencoded. When dictionary is cloned, a new handler is created.
|
|
/// Each handler is unique to dictionary.
|
|
class ExternalDictionaryLibraryBridgeRequestHandler : public HTTPRequestHandler, WithContext
|
|
{
|
|
public:
|
|
ExternalDictionaryLibraryBridgeRequestHandler(size_t keep_alive_timeout_, ContextPtr context_);
|
|
|
|
void handleRequest(HTTPServerRequest & request, HTTPServerResponse & response) override;
|
|
|
|
private:
|
|
static constexpr inline auto FORMAT = "RowBinary";
|
|
|
|
Poco::Logger * log;
|
|
size_t keep_alive_timeout;
|
|
};
|
|
|
|
|
|
class ExternalDictionaryLibraryBridgeExistsHandler : public HTTPRequestHandler, WithContext
|
|
{
|
|
public:
|
|
ExternalDictionaryLibraryBridgeExistsHandler(size_t keep_alive_timeout_, ContextPtr context_);
|
|
|
|
void handleRequest(HTTPServerRequest & request, HTTPServerResponse & response) override;
|
|
|
|
private:
|
|
const size_t keep_alive_timeout;
|
|
Poco::Logger * log;
|
|
};
|
|
|
|
}
|