ClickHouse/tests
Robert Schulze 60f9f6855d
feat: implement catboost in library-bridge
This commit moves the catboost model evaluation out of the server
process into the library-bridge binary. This serves two goals: On the
one hand, crashes / memory corruptions of the catboost library no longer
affect the server. On the other hand, we can forbid loading dynamic
libraries in the server (catboost was the last consumer of this
functionality), thus improving security.

SQL syntax:

  SELECT
    catboostEvaluate('/path/to/model.bin', FEAT_1, ..., FEAT_N) > 0 AS prediction,
    ACTION AS target
  FROM amazon_train
  LIMIT 10

Required configuration:

  <catboost_lib_path>/path/to/libcatboostmodel.so</catboost_lib_path>

*** Implementation Details ***

The internal protocol between the server and the library-bridge is
simple:

- HTTP GET on path "/extdict_ping":
  A ping, used during the handshake to check if the library-bridge runs.

- HTTP POST on path "extdict_request"
  (1) Send a "catboost_GetTreeCount" request from the server to the
      bridge, containing a library path (e.g /home/user/libcatboost.so) and
      a model path (e.g. /home/user/model.bin). Rirst, this unloads the
      catboost library handler associated to the model path (if it was
      loaded), then loads the catboost library handler associated to the
      model path, then executes GetTreeCount() on the library handler and
      finally sends the result back to the server. Step (1) is called once
      by the server from FunctionCatBoostEvaluate::getReturnTypeImpl(). The
      library path handler is unloaded in the beginning because it contains
      state which may no longer be valid if the user runs
      catboost("/path/to/model.bin", ...) more than once and if "model.bin"
      was updated in between.
  (2) Send "catboost_Evaluate" from the server to the bridge, containing
      the model path and the features to run the interference on. Step (2)
      is called multiple times (once per chunk) by the server from function
      FunctionCatBoostEvaluate::executeImpl(). The library handler for the
      given model path is expected to be already loaded by Step (1).

Fixes #27870
2022-09-08 09:01:32 +00:00
..
ci Merge pull request #40999 from ClickHouse/sse2-special-build 2022-09-08 09:06:29 +02:00
config Merge branch 'kssenii-fix-write-through-cache-logical-error' into stress_s3 2022-08-30 18:44:14 +02:00
fuzz Revert "Move CatBoost evaluation into clickhouse-library-bridge" 2022-08-31 20:54:43 +02:00
instructions Enable clang-tidy for headers 2022-08-31 10:48:15 +00:00
integration feat: implement catboost in library-bridge 2022-09-08 09:01:32 +00:00
jepsen.clickhouse-keeper Remove the remaining parts of "unbundled" build 2022-08-27 02:18:47 +02:00
perf_drafts
performance Skip empty literals in lz4 decompression (#40142) 2022-09-06 13:58:26 +02:00
queries Merge pull request #40873 from azat/build/fix-debug-symbols-quirk 2022-09-07 17:31:35 +02:00
.gitignore
clickhouse-test Update clickhouse-test 2022-09-01 14:26:50 +03:00
CMakeLists.txt
msan_suppressions.txt
tsan_suppressions.txt
ubsan_suppressions.txt