Skip to content

Instantly share code, notes, and snippets.

// endless loop for EV_CLOSED with the patch applied from
// https://github.com/libevent/libevent/issues/984
#include <event2/event.h>
#include <unistd.h>
#include <assert.h>
#include <sys/socket.h>
void readcb(int fd, short events, void *arg)
{
#!/usr/bin/env python3
# reformat each SHOW CREATE query for multiline:
# https://github.com/ClickHouse/ClickHouse/pull/10049
import sys
import os
import subprocess
def format_sql(sql, **kwargs):
#!/usr/bin/env -S PYTHONHASHSEED=0 python3
# Highlight kafka debug logs:
#
# kafka debug cgrp,consumer,topic,protocol
#
# Usage example:
#
# kafkalog.py < kafka.log | less -R
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <evhttp.h>
#include <event2/event.h>
#include <event2/http.h>
#include <event2/bufferevent.h>
void http_request_done(struct evhttp_request *req, void *arg){
diff --git a/programs/benchmark/Benchmark.cpp b/programs/benchmark/Benchmark.cpp
index 91c43160e0..fed4823369 100644
--- a/programs/benchmark/Benchmark.cpp
+++ b/programs/benchmark/Benchmark.cpp
@@ -521,6 +521,11 @@ int mainEntryClickHouseBenchmark(int argc, char ** argv)
{
using boost::program_options::value;
+ const char *val = nullptr;
+ size_t size = sizeof(val);
/// Copied from https://docs.microsoft.com/en-us/windows/win32/api/iptypes/ns-iptypes-ip_adapter_addresses_lh
#include <winsock2.h>
#include <iphlpapi.h>
#include <stdio.h>
#pragma comment(lib, "IPHLPAPI.lib")
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
// Copied from ClickHouse sources
// https://github.com/ClickHouse/ClickHouse/pull/11590
#include <cstdlib>
#include <cstring>
#include <vector>
#include <thread>
#include <iostream>
// - jemalloc:
function array_exist()
{
local needle="$1"
shift
local i
for i; do
[ "$needle" = "$i" ] && return 0 || continue
done
return 1
/**
* Reproducer for percpu_arena jemalloc issue [1].
* Requires debug jemalloc (w/o NDEBUG to include assert()s)
*
* [1]: https://github.com/jemalloc/jemalloc/pull/1676
*
* $ gcc -g3 -o /tmp/sched /tmp/sched.c
* $ MALLOC_CONF=percpu_arena:percpu LD_PRELOAD=jemalloc/build/lib/libjemalloc.so taskset --cpu-list 3 /tmp/sched
* <jemalloc>: ../src/jemalloc.c:321: Failed assertion: "ind <= narenas_total_get()"
* Aborted (core dumped)
2020-09-22 00:48:35 01502_jemalloc_percpu_arena: [ FAIL ] 7.43 sec. - return code 66
2020-09-22 00:48:35 ==================
2020-09-22 00:48:35 WARNING: ThreadSanitizer: data race (pid=384)
2020-09-22 00:48:35 Write of size 8 at 0x7b1000008ff8 by main thread (mutexes: write M1432):
2020-09-22 00:48:35 #0 operator delete(void*, unsigned long) <null> (clickhouse+0x8085f1e)
2020-09-22 00:48:35 #1 Poco::Logger::~Logger() /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp:39:1 (clickhouse+0x14dc78ce)
2020-09-22 00:48:35 #2 non-virtual thunk to Poco::Logger::~Logger() /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/src/Logger.cpp (clickhouse+0x14dc78ce)
2020-09-22 00:48:35 #3 Poco::RefCountedObject::release() const /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/include/Poco/RefCountedObject.h:82:24 (clickhouse+0x14dcb797)
2020-09-22 00:48:35 #4 Poco::Logger::shutdown() /build/obj-x86_64-linux-gnu/../contrib/poco/Found