OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
/home/jenkins-slave/workspace/core-os-doxygen/HeavyDB.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
19 #ifdef HAVE_THRIFT_MESSAGE_LIMIT
20 #include "Shared/ThriftConfig.h"
21 #endif
22 
23 #ifdef HAVE_THRIFT_THREADFACTORY
24 #include <thrift/concurrency/ThreadFactory.h>
25 #else
26 #include <thrift/concurrency/PlatformThreadFactory.h>
27 #endif
28 
29 #include <thrift/concurrency/ThreadManager.h>
30 #include <thrift/protocol/TBinaryProtocol.h>
31 #include <thrift/server/TThreadedServer.h>
32 #include <thrift/transport/TBufferTransports.h>
33 #include <thrift/transport/THttpServer.h>
34 #include <thrift/transport/TSSLServerSocket.h>
35 #include <thrift/transport/TSSLSocket.h>
36 #include <thrift/transport/TServerSocket.h>
38 
39 #include "Logger/Logger.h"
41 #include "Shared/file_delete.h"
43 #include "Shared/misc.h"
44 #include "Shared/scope.h"
45 
46 #include <boost/algorithm/string.hpp>
47 #include <boost/algorithm/string/trim.hpp>
48 #include <boost/filesystem.hpp>
49 #include <boost/locale/generator.hpp>
50 #include <boost/make_shared.hpp>
51 #include <boost/program_options.hpp>
52 
53 #ifdef ENABLE_TBB
54 #include <tbb/global_control.h>
55 #endif
56 
57 #ifdef __linux__
58 #include <unistd.h>
59 #endif
60 
61 #include <csignal>
62 #include <cstdlib>
63 #include <sstream>
64 #include <thread>
65 #include <vector>
66 
67 #ifdef HAVE_AWS_S3
68 #include "DataMgr/HeavyDbAwsSdk.h"
69 #endif
72 #include "Shared/Compressor.h"
74 #include "Shared/file_delete.h"
75 #include "Shared/scope.h"
77 
78 using namespace ::apache::thrift;
79 using namespace ::apache::thrift::concurrency;
80 using namespace ::apache::thrift::protocol;
81 using namespace ::apache::thrift::server;
82 using namespace ::apache::thrift::transport;
83 
84 extern bool g_enable_thrift_logs;
85 
86 // Set g_running to false to trigger normal server shutdown.
87 std::atomic<bool> g_running{true};
88 
89 extern bool g_enable_http_binary_server;
90 
91 namespace { // anonymous
92 
93 std::atomic<int> g_saw_signal{-1};
94 
95 std::shared_ptr<TThreadedServer> g_thrift_http_server;
96 std::shared_ptr<TThreadedServer> g_thrift_http_binary_server;
97 std::shared_ptr<TThreadedServer> g_thrift_tcp_server;
98 
99 std::shared_ptr<DBHandler> g_warmup_handler;
100 // global "g_warmup_handler" needed to avoid circular dependency
101 // between "DBHandler" & function "run_warmup_queries"
102 
103 std::shared_ptr<DBHandler> g_db_handler;
104 
105 void register_signal_handler(int signum, void (*handler)(int)) {
106 #ifdef _WIN32
107  signal(signum, handler);
108 #else
109  struct sigaction act;
110  memset(&act, 0, sizeof(act));
111  if (handler != SIG_DFL && handler != SIG_IGN) {
112  // block all signal deliveries while inside the signal handler
113  sigfillset(&act.sa_mask);
114  }
115  act.sa_handler = handler;
116  sigaction(signum, &act, NULL);
117 #endif
118 }
119 
120 // Signal handler to set a global flag telling the server to exit.
121 // Do not call other functions inside this (or any) signal handler
122 // unless you really know what you are doing. See also:
123 // man 7 signal-safety
124 // man 7 signal
125 // https://en.wikipedia.org/wiki/Reentrancy_(computing)
126 void heavydb_signal_handler(int signum) {
127  // Record the signal number for logging during shutdown.
128  // Only records the first signal if called more than once.
129  int expected_signal{-1};
130  if (!g_saw_signal.compare_exchange_strong(expected_signal, signum)) {
131  return; // this wasn't the first signal
132  }
133 
134  // This point should never be reached more than once.
135 
136  // Tell heartbeat() to shutdown by unsetting the 'g_running' flag.
137  // If 'g_running' is already false, this has no effect and the
138  // shutdown is already in progress.
139  g_running = false;
140 
141  // Handle core dumps specially by pausing inside this signal handler
142  // because on some systems, some signals will execute their default
143  // action immediately when and if the signal handler returns.
144  // We would like to do some emergency cleanup before core dump.
145  if (signum == SIGABRT || signum == SIGSEGV || signum == SIGFPE
146 #ifndef _WIN32
147  || signum == SIGQUIT
148 #endif
149  ) {
150  // Wait briefly to give heartbeat() a chance to flush the logs and
151  // do any other emergency shutdown tasks.
152  std::this_thread::sleep_for(std::chrono::seconds(2));
153 
154  // Explicitly trigger whatever default action this signal would
155  // have done, such as terminate the process or dump core.
156  // Signals are currently blocked so this new signal will be queued
157  // until this signal handler returns.
158  register_signal_handler(signum, SIG_DFL);
159 #ifdef _WIN32
160  raise(signum);
161 #else
162  kill(getpid(), signum);
163 #endif
164  std::this_thread::sleep_for(std::chrono::seconds(5));
165 
166 #ifndef __APPLE__
167  // as a last resort, abort
168  // primary used in Docker environments, where we can end up with PID 1 and fail to
169  // catch unix signals
170  quick_exit(signum);
171 #endif
172  }
173 }
174 
177 #ifndef _WIN32
180 #endif
184 #ifndef _WIN32
185  // Thrift secure socket can cause problems with SIGPIPE
186  register_signal_handler(SIGPIPE, SIG_IGN);
187 #endif
188 }
189 } // anonymous namespace
190 
191 void start_server(std::shared_ptr<TThreadedServer> server, const int port) {
192  try {
193  server->serve();
194  if (errno != 0) {
195  throw std::runtime_error(std::string("Thrift server exited: ") +
196  std::strerror(errno));
197  }
198  } catch (std::exception& e) {
199  LOG(ERROR) << "Exception: " << e.what() << ": port " << port << std::endl;
200  }
201 }
202 
203 void releaseWarmupSession(TSessionId& sessionId, std::ifstream& query_file) noexcept {
204  query_file.close();
205  if (sessionId != g_warmup_handler->getInvalidSessionId()) {
206  try {
207  g_warmup_handler->disconnect(sessionId);
208  } catch (...) {
209  LOG(ERROR) << "Failed to disconnect warmup session, possible failure to run warmup "
210  "queries.";
211  }
212  }
213 }
214 
215 void run_warmup_queries(std::shared_ptr<DBHandler> handler,
216  std::string base_path,
217  std::string query_file_path) {
218  // run warmup queries to load cache if requested
219  if (query_file_path.empty()) {
220  return;
221  }
222  if (handler->isAggregator()) {
223  LOG(INFO) << "Skipping warmup query execution on the aggregator, queries should be "
224  "run directly on the leaf nodes.";
225  return;
226  }
227 
228  LOG(INFO) << "Running DB warmup with queries from " << query_file_path;
229  try {
230  g_warmup_handler = handler;
231  std::string db_info;
232  std::string user_keyword, user_name, db_name;
233  std::ifstream query_file;
236  TSessionId sessionId = g_warmup_handler->getInvalidSessionId();
237 
238  ScopeGuard session_guard = [&] { releaseWarmupSession(sessionId, query_file); };
239  query_file.open(query_file_path);
240  while (std::getline(query_file, db_info)) {
241  if (db_info.length() == 0) {
242  continue;
243  }
244  std::istringstream iss(db_info);
245  iss >> user_keyword >> user_name >> db_name;
246  if (user_keyword.compare(0, 4, "USER") == 0) {
247  // connect to DB for given user_name/db_name with super_user_rights (without
248  // password), & start session
249  g_warmup_handler->super_user_rights_ = true;
250  g_warmup_handler->connect(sessionId, user_name, "", db_name);
251  g_warmup_handler->super_user_rights_ = false;
252 
253  // read and run one query at a time for the DB with the setup connection
254  TQueryResult ret;
255  std::string single_query;
256  while (std::getline(query_file, single_query)) {
257  boost::algorithm::trim(single_query);
258  if (single_query.length() == 0 || single_query[0] == '-') {
259  continue;
260  }
261  if (single_query[0] == '}') {
262  single_query.clear();
263  break;
264  }
265  if (single_query.find(';') == single_query.npos) {
266  std::string multiline_query;
267  std::getline(query_file, multiline_query, ';');
268  single_query += multiline_query;
269  }
270 
271  try {
272  g_warmup_handler->sql_execute(ret, sessionId, single_query, true, "", -1, -1);
273  } catch (...) {
274  LOG(WARNING) << "Exception while executing '" << single_query
275  << "', ignoring";
276  }
277  single_query.clear();
278  }
279 
280  // stop session and disconnect from the DB
281  g_warmup_handler->disconnect(sessionId);
282  sessionId = g_warmup_handler->getInvalidSessionId();
283  } else {
284  LOG(WARNING) << "\nSyntax error in the file: " << query_file_path.c_str()
285  << " Missing expected keyword USER. Following line will be ignored: "
286  << db_info.c_str() << std::endl;
287  }
288  db_info.clear();
289  }
290  } catch (const std::exception& e) {
291  LOG(WARNING)
292  << "Exception while executing warmup queries. "
293  << "Warmup may not be fully completed. Will proceed nevertheless.\nError was: "
294  << e.what();
295  }
296 }
297 
299 extern bool g_enable_fsi;
301 
302 void thrift_stop() {
303  if (auto thrift_http_server = g_thrift_http_server; thrift_http_server) {
304  thrift_http_server->stop();
305  }
306  g_thrift_http_server.reset();
307 
308  if (auto thrift_http_binary_server = g_thrift_http_binary_server;
309  thrift_http_binary_server) {
310  thrift_http_binary_server->stop();
311  }
312  g_thrift_http_binary_server.reset();
313 
314  if (auto thrift_tcp_server = g_thrift_tcp_server; thrift_tcp_server) {
315  thrift_tcp_server->stop();
316  }
317  g_thrift_tcp_server.reset();
318 }
319 
320 void heartbeat() {
321 #ifndef _WIN32
322  // Block all signals for this heartbeat thread, only.
323  sigset_t set;
324  sigfillset(&set);
325  int result = pthread_sigmask(SIG_BLOCK, &set, NULL);
326  if (result != 0) {
327  throw std::runtime_error("heartbeat() thread startup failed");
328  }
329 #endif
330 
331  // Sleep until heavydb_signal_handler or anything clears the g_running flag.
332  VLOG(1) << "heartbeat thread starting";
333  while (::g_running) {
334  using namespace std::chrono;
335  std::this_thread::sleep_for(1s);
336  }
337  VLOG(1) << "heartbeat thread exiting";
338 
339  // Get the signal number if there was a signal.
340  int signum = g_saw_signal;
341  if (signum >= 1 && signum != SIGTERM) {
342  LOG(INFO) << "Interrupt signal (" << signum << ") received.";
343  }
344 
345  // If dumping core, try to do some quick stuff.
346  if (signum == SIGABRT || signum == SIGSEGV || signum == SIGFPE
347 #ifndef _WIN32
348  || signum == SIGQUIT
349 #endif
350  ) {
351  // Need to shut down calcite.
352  if (auto db_handler = g_db_handler; db_handler) {
353  db_handler->emergency_shutdown();
354  }
355  // Need to flush the logs for debugging.
357  return;
358  // Core dump should begin soon after this. See heavydb_signal_handler().
359  // We leave the rest of the server process as is for the core dump image.
360  }
361 
362  // Stopping the Thrift thread(s) will allow main() to return.
363  thrift_stop();
364 }
365 
366 #ifdef HAVE_THRIFT_MESSAGE_LIMIT
367 namespace {
368 class UnboundedTBufferedTransportFactory : public TBufferedTransportFactory {
369  public:
370  UnboundedTBufferedTransportFactory() : TBufferedTransportFactory() {}
371 
372  std::shared_ptr<TTransport> getTransport(
373  std::shared_ptr<TTransport> transport) override {
374  return std::make_shared<TBufferedTransport>(transport, shared::default_tconfig());
375  }
376 };
377 
378 class UnboundedTHttpServerTransportFactory : public THttpServerTransportFactory {
379  public:
380  UnboundedTHttpServerTransportFactory() : THttpServerTransportFactory() {}
381 
382  std::shared_ptr<TTransport> getTransport(
383  std::shared_ptr<TTransport> transport) override {
384  return std::make_shared<THttpServer>(transport, shared::default_tconfig());
385  }
386 };
387 } // namespace
388 #endif
389 
391  bool start_http_server = true) {
392  // Prepare to launch the Thrift server.
393  LOG(INFO) << "HeavyDB starting up";
395 #ifdef ENABLE_TBB
396  auto num_cpu_threads = cpu_threads();
397  LOG(INFO) << "Initializing TBB with " << num_cpu_threads << " threads.";
398  tbb::global_control tbb_control(tbb::global_control::max_allowed_parallelism,
399  num_cpu_threads);
400  threading_tbb::g_tbb_arena.initialize(num_cpu_threads);
401  const int32_t tbb_max_concurrency{threading_tbb::g_tbb_arena.max_concurrency()};
402  LOG(INFO) << "TBB max concurrency: " << tbb_max_concurrency << " threads.";
403 #endif // ENABLE_TBB
404 #ifdef HAVE_AWS_S3
406 #endif // HAVE_AWS_S3
407  std::set<std::unique_ptr<std::thread>> server_threads;
408  auto wait_for_server_threads = [&] {
409  for (auto& th : server_threads) {
410  try {
411  th->join();
412  } catch (const std::system_error& e) {
413  if (e.code() != std::errc::invalid_argument) {
414  LOG(WARNING) << "std::thread join failed: " << e.what();
415  }
416  } catch (const std::exception& e) {
417  LOG(WARNING) << "std::thread join failed: " << e.what();
418  } catch (...) {
419  LOG(WARNING) << "std::thread join failed";
420  }
421  }
422  };
423  ScopeGuard server_shutdown_guard = [&] {
424  // This function will never be called by exit(), but we shouldn't ever be calling
425  // exit(), we should be setting g_running to false instead.
426  LOG(INFO) << "HeavyDB shutting down";
427 
428  g_running = false;
429 
430  thrift_stop();
431 
432  if (g_enable_fsi) {
434  }
435 
436  g_db_handler.reset();
437 
438  wait_for_server_threads();
439 
440 #ifdef HAVE_AWS_S3
442 #endif // HAVE_AWS_S3
443 
444  // Flush the logs last to capture maximum debugging information.
446  };
447 
448  // start background thread to clean up _DELETE_ME files
449  const unsigned int wait_interval =
450  3; // wait time in secs after looking for deleted file before looking again
451  server_threads.insert(std::make_unique<std::thread>(
452  file_delete,
453  std::ref(g_running),
454  wait_interval,
455  prog_config_opts.base_path + "/" + shared::kDataDirectoryName));
456  server_threads.insert(std::make_unique<std::thread>(heartbeat));
457 
458  if (!g_enable_thrift_logs) {
459  apache::thrift::GlobalOutput.setOutputFunction([](const char* msg) {});
460  }
461 
462  // Thrift event handler for database server setup.
463  try {
464  if (prog_config_opts.system_parameters.master_address.empty()) {
465  // Handler for a single database server. (DBHandler)
466  g_db_handler =
467  std::make_shared<DBHandler>(prog_config_opts.db_leaves,
468  prog_config_opts.string_leaves,
469  prog_config_opts.base_path,
470  prog_config_opts.allow_multifrag,
471  prog_config_opts.jit_debug,
472  prog_config_opts.intel_jit_profile,
473  prog_config_opts.read_only,
474  prog_config_opts.allow_loop_joins,
475  prog_config_opts.enable_rendering,
476  prog_config_opts.renderer_prefer_igpu,
477  prog_config_opts.renderer_vulkan_timeout_ms,
478  prog_config_opts.renderer_use_parallel_executors,
479  prog_config_opts.enable_auto_clear_render_mem,
480  prog_config_opts.render_oom_retry_threshold,
481  prog_config_opts.render_mem_bytes,
482  prog_config_opts.max_concurrent_render_sessions,
483  prog_config_opts.reserved_gpu_mem,
484  prog_config_opts.render_compositor_use_last_gpu,
485  prog_config_opts.renderer_enable_slab_allocation,
486  prog_config_opts.num_reader_threads,
487  prog_config_opts.authMetadata,
488  prog_config_opts.system_parameters,
489  prog_config_opts.enable_legacy_syntax,
490  prog_config_opts.idle_session_duration,
491  prog_config_opts.max_session_duration,
492  prog_config_opts.udf_file_name,
493  prog_config_opts.udf_compiler_path,
494  prog_config_opts.udf_compiler_options,
495 #ifdef ENABLE_GEOS
496  prog_config_opts.libgeos_so_filename,
497 #endif
498 #ifdef HAVE_TORCH_TFS
499  prog_config_opts.torch_lib_path,
500 #endif
501  prog_config_opts.disk_cache_config,
502  false);
503  } else { // running ha server
504  LOG(FATAL)
505  << "No High Availability module available, please contact OmniSci support";
506  }
507  } catch (const std::exception& e) {
508  LOG(FATAL) << "Failed to initialize service handler: " << e.what();
509  }
510 
511  // do the drop render group columns migration here too
512  // @TODO make a single entry point in MigrationMgr that will do these two and futures
514 
515  // Recover from any partially complete alter table alter column commands
518 
519  if (g_enable_fsi && g_enable_foreign_table_scheduled_refresh) {
521  }
522 
523  // TCP port setup. We use Thrift both for a TCP socket and for an optional HTTP socket.
524  std::shared_ptr<TServerSocket> tcp_socket;
525  std::shared_ptr<TServerSocket> http_socket;
526  std::shared_ptr<TServerSocket> http_binary_socket;
527 
528  if (!prog_config_opts.system_parameters.ssl_cert_file.empty() &&
529  !prog_config_opts.system_parameters.ssl_key_file.empty()) {
530  // SSL port setup.
531  auto sslSocketFactory = std::make_shared<TSSLSocketFactory>(SSLProtocol::SSLTLS);
532  sslSocketFactory->loadCertificate(
533  prog_config_opts.system_parameters.ssl_cert_file.c_str());
534  sslSocketFactory->loadPrivateKey(
535  prog_config_opts.system_parameters.ssl_key_file.c_str());
536  if (prog_config_opts.system_parameters.ssl_transport_client_auth) {
537  sslSocketFactory->authenticate(true);
538  } else {
539  sslSocketFactory->authenticate(false);
540  }
541  sslSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
542  tcp_socket = std::make_shared<TSSLServerSocket>(
543  prog_config_opts.system_parameters.omnisci_server_port, sslSocketFactory);
544  if (start_http_server) {
545  http_socket = std::make_shared<TSSLServerSocket>(prog_config_opts.http_port,
546  sslSocketFactory);
547  }
549  http_binary_socket = std::make_shared<TSSLServerSocket>(
550  prog_config_opts.http_binary_port, sslSocketFactory);
551  }
552  LOG(INFO) << " HeavyDB server using encrypted connection. Cert file ["
553  << prog_config_opts.system_parameters.ssl_cert_file << "], key file ["
554  << prog_config_opts.system_parameters.ssl_key_file << "]";
555 
556  } else {
557  // Non-SSL port setup.
558  LOG(INFO) << " HeavyDB server using unencrypted connection";
559  tcp_socket = std::make_shared<TServerSocket>(
560  prog_config_opts.system_parameters.omnisci_server_port);
561  if (start_http_server) {
562  http_socket = std::make_shared<TServerSocket>(prog_config_opts.http_port);
563  }
565  http_binary_socket =
566  std::make_shared<TServerSocket>(prog_config_opts.http_binary_port);
567  }
568  }
569 
570  // Thrift uses the same processor for both the TCP port and the HTTP port.
571  std::shared_ptr<TProcessor> processor{std::make_shared<TrackingProcessor>(
572  g_db_handler, prog_config_opts.log_user_origin)};
573 
574  // Thrift TCP server launch.
575  std::shared_ptr<TServerTransport> tcp_st = tcp_socket;
576 #ifdef HAVE_THRIFT_MESSAGE_LIMIT
577  std::shared_ptr<TTransportFactory> tcp_tf{
578  std::make_shared<UnboundedTBufferedTransportFactory>()};
579 #else
580  std::shared_ptr<TTransportFactory> tcp_tf{
581  std::make_shared<TBufferedTransportFactory>()};
582 #endif
583  std::shared_ptr<TProtocolFactory> tcp_pf{std::make_shared<TBinaryProtocolFactory>()};
584  g_thrift_tcp_server.reset(new TThreadedServer(processor, tcp_st, tcp_tf, tcp_pf));
585  server_threads.insert(std::make_unique<std::thread>(
586  start_server,
587  g_thrift_tcp_server,
588  prog_config_opts.system_parameters.omnisci_server_port));
589 
590  // Thrift HTTP server launch.
591  if (start_http_server) {
592  std::shared_ptr<TServerTransport> http_st = http_socket;
593 #ifdef HAVE_THRIFT_MESSAGE_LIMIT
594  std::shared_ptr<TTransportFactory> http_tf{
595  std::make_shared<UnboundedTHttpServerTransportFactory>()};
596 #else
597  std::shared_ptr<TTransportFactory> http_tf{
598  std::make_shared<THttpServerTransportFactory>()};
599 #endif
600  std::shared_ptr<TProtocolFactory> http_pf{std::make_shared<TJSONProtocolFactory>()};
601  g_thrift_http_server.reset(new TThreadedServer(processor, http_st, http_tf, http_pf));
602  server_threads.insert(std::make_unique<std::thread>(
603  start_server, g_thrift_http_server, prog_config_opts.http_port));
604  }
605 
606  // Thrift HTTP binary protocol server launch.
608  std::shared_ptr<TServerTransport> http_binary_st = http_binary_socket;
609 #ifdef HAVE_THRIFT_MESSAGE_LIMIT
610  std::shared_ptr<TTransportFactory> http_binary_tf{
611  std::make_shared<UnboundedTHttpServerTransportFactory>()};
612 #else
613  std::shared_ptr<TTransportFactory> http_binary_tf{
614  std::make_shared<THttpServerTransportFactory>()};
615 #endif
616  std::shared_ptr<TProtocolFactory> http_binary_pf{
617  std::make_shared<TBinaryProtocolFactory>()};
618  g_thrift_http_binary_server.reset(
619  new TThreadedServer(processor, http_binary_st, http_binary_tf, http_binary_pf));
620  server_threads.insert(std::make_unique<std::thread>(
621  start_server, g_thrift_http_binary_server, prog_config_opts.http_binary_port));
622  }
623 
624  // Run warm up queries if any exist.
626  g_db_handler, prog_config_opts.base_path, prog_config_opts.db_query_file);
627  if (prog_config_opts.exit_after_warmup) {
628  g_running = false;
629  }
630 
631  // Main thread blocks for as long as the servers are running.
632  wait_for_server_threads();
633 
634  // Clean shutdown.
635  int signum = g_saw_signal;
636  if (signum <= 0 || signum == SIGTERM) {
637  return 0;
638  } else {
639  return signum;
640  }
641 }
642 
644 #ifdef __linux__
645  VLOG(1) << "sysconf(_SC_PAGE_SIZE): " << sysconf(_SC_PAGE_SIZE);
646  VLOG(1) << "/proc/buddyinfo: " << shared::FileContentsEscaper{"/proc/buddyinfo"};
647  VLOG(1) << "/proc/meminfo: " << shared::FileContentsEscaper{"/proc/meminfo"};
648 #endif
649 }
650 
651 int main(int argc, char** argv) {
652  bool has_clust_topo = false;
653 
654  CommandLineOptions prog_config_opts(argv[0], has_clust_topo);
655 
656  try {
657  if (auto return_code =
658  prog_config_opts.parse_command_line(argc, argv, !has_clust_topo)) {
659  return *return_code;
660  }
661 
662  if (!has_clust_topo) {
663  prog_config_opts.validate_base_path();
664  prog_config_opts.validate();
666  return (startHeavyDBServer(prog_config_opts));
667  }
668  } catch (std::runtime_error& e) {
669  std::cerr << "Server Error: " << e.what() << std::endl;
670  return 1;
671  } catch (boost::program_options::error& e) {
672  std::cerr << "Usage Error: " << e.what() << std::endl;
673  return 1;
674  }
675 }
const std::string kDataDirectoryName
void run_warmup_queries(std::shared_ptr< DBHandler > handler, std::string base_path, std::string query_file_path)
Definition: HeavyDB.cpp:215
unsigned renderer_vulkan_timeout_ms
std::vector< LeafHostInfo > string_leaves
std::string udf_compiler_path
std::shared_ptr< DBHandler > g_db_handler
Definition: HeavyDB.cpp:103
#define LOG(tag)
Definition: Logger.h:285
void heartbeat()
Definition: HeavyDB.cpp:320
shared utility for the db server and string dictionary server to remove old files ...
void start_server(std::shared_ptr< TThreadedServer > server, const int port)
Definition: HeavyDB.cpp:191
void checkDropRenderGroupColumnsMigration() const
std::shared_ptr< TThreadedServer > g_thrift_http_binary_server
Definition: HeavyDB.cpp:96
boost::optional< int > parse_command_line(int argc, char const *const *argv, const bool should_init_logging=false)
std::atomic< int > g_saw_signal
Definition: HeavyDB.cpp:93
size_t max_concurrent_render_sessions
static SysCatalog & instance()
Definition: SysCatalog.h:343
singleton class to handle concurrancy and state for blosc library. A C++ wrapper over a pure C librar...
tbb::task_arena g_tbb_arena
std::shared_ptr< apache::thrift::TConfiguration > default_tconfig()
Definition: ThriftConfig.h:26
std::vector< LeafHostInfo > db_leaves
int startHeavyDBServer(CommandLineOptions &prog_config_opts, bool start_http_server=true)
Definition: HeavyDB.cpp:390
bool g_enable_http_binary_server
std::shared_ptr< TThreadedServer > g_thrift_http_server
Definition: HeavyDB.cpp:95
std::string ssl_key_file
AuthMetadata authMetadata
void log_startup_info()
Definition: HeavyDB.cpp:643
static void start(std::atomic< bool > &is_program_running)
void shutdown()
Definition: Logger.cpp:401
std::vector< std::string > udf_compiler_options
bool g_enable_foreign_table_scheduled_refresh
void register_signal_handler(int signum, void(*handler)(int))
Definition: HeavyDB.cpp:105
std::shared_ptr< DBHandler > g_warmup_handler
Definition: HeavyDB.cpp:99
std::atomic< bool > g_running
Definition: HeavyDB.cpp:87
File_Namespace::DiskCacheConfig disk_cache_config
void file_delete(std::atomic< bool > &program_is_running, const unsigned int wait_interval_seconds, const std::string base_path)
Definition: File.cpp:272
bool g_enable_fsi
Definition: Catalog.cpp:96
int cpu_threads()
Definition: thread_count.h:25
bool g_enable_thrift_logs
Definition: HeavyDB.cpp:298
void heavydb_signal_handler(int signum)
Definition: HeavyDB.cpp:126
#define VLOG(n)
Definition: Logger.h:388
void releaseWarmupSession(TSessionId &sessionId, std::ifstream &query_file) noexcept
Definition: HeavyDB.cpp:203
void thrift_stop()
Definition: HeavyDB.cpp:302
std::string master_address
std::shared_ptr< TThreadedServer > g_thrift_tcp_server
Definition: HeavyDB.cpp:97
SystemParameters system_parameters
std::string ssl_cert_file