ClickHouse® is a real-time analytics DBMS
Go to file
Azat Khuzhin 9276384977 clickhouse-test: do not use random generator with shared state
Recently (#32094) test database had been overlapped, and random prefix
for database had been increased from 6 to 8.

But actually 6 bytes for random prefix should be enough (with existing
alphabet (0-9a-z) it is 36**6=2'176'782'336), and the real reason of
this overlap is that random generator by default uses shared state [1]:

    The functions supplied by this module are actually bound methods of
    a hidden instance of the random.Random class. You can instantiate your
    own instances of Random to get generators that don’t share state.

  [1]: https://docs.python.org/3/library/random.html

I've played a little bit with random in python, and using default random
generator it generates non-unique strings pretty fast, just in a few
runs, but using SystemRandom (that uses /dev/urandom) it takes ~1 minute.

Test:

```sh
    $ while /tmp/test.py | LANG=c sort -S5G | LANG=c uniq -d | tee /dev/stderr | wc -l | fgrep -q -x -c 0; do :; done
```

```python
    #!/usr/bin/env python3

    import multiprocessing
    import string
    import random

    def random_str(length=6):
        alphabet = string.ascii_lowercase + string.digits
        return ''.join(random.SystemRandom().choice(alphabet) for _ in range(length))

    def worker(_):
        print(random_str())

    with multiprocessing.Pool(processes=2) as pool:
        pool.map(worker, range(0, int(10e3)))
```

So let's switch to SystemRandom and use 6-byte prefix.
2021-12-03 01:29:23 +03:00
.github Remove PVS check from master 2021-12-02 11:36:30 +03:00
base Fix magic_enum for debug helpers 2021-11-28 06:28:19 +03:00
benchmark Add benchmark for DuckDB 2021-10-31 21:05:07 +03:00
cmake Merge pull request #31951 from Algunenano/libcxx13 2021-11-30 05:23:23 +03:00
contrib Update contrib/sysroot: fix symlink 2021-12-01 17:10:28 +01:00
debian Auto version update to [21.12.1.1] [54457] 2021-11-02 00:56:45 +03:00
docker Provide clickhouse binary w/o debug symbols (stripped) in fasttest 2021-12-01 21:50:03 +03:00
docs Fix syntax error: drop comma 2021-12-01 20:12:10 +00:00
programs Merge pull request #31802 from pkit/fix_setcap 2021-11-30 05:49:03 +03:00
src Add exception/exception_code to trace span log (#32040) 2021-12-03 01:00:02 +03:00
tests clickhouse-test: do not use random generator with shared state 2021-12-03 01:29:23 +03:00
utils Fix style-check for ProfileEvents checking 2021-12-01 10:26:00 +03:00
website Update featured image for 21.11 release blog post 2021-12-02 10:28:47 -07:00
.clang-format Fixed wrong code around Memory Profiler 2020-03-03 03:24:44 +03:00
.clang-tidy Revert "Revert "Fix tidy"" 2021-09-06 12:16:52 +03:00
.editorconfig Changed tabs to spaces in editor configs and in style guide [#CLICKHOUSE-3]. 2017-04-01 11:35:09 +03:00
.gitattributes Union merge for arcadia_skip_list.txt to avoid frequent conflicts 2021-03-10 08:50:32 +03:00
.gitignore fix style check 2021-09-21 10:28:33 +03:00
.gitmodules Merge pull request #31951 from Algunenano/libcxx13 2021-11-30 05:23:23 +03:00
.potato.yml Fix yamllint issues 2021-02-20 23:25:21 +03:00
.pylintrc Add pylintrc config 2021-01-26 23:35:56 +03:00
.vimrc Changed tabs to spaces in editor configs and in style guide [#CLICKHOUSE-3]. 2017-04-01 11:35:09 +03:00
.yamllint Drop truthy.check-keys from yamllint (does not supported on CI) 2021-02-21 06:15:36 +03:00
AUTHORS Update AUTHORS 2021-09-22 11:38:03 +03:00
CHANGELOG.md Update CHANGELOG.md 2021-11-18 12:50:41 +03:00
CMakeLists.txt Merge pull request #31957 from traceon/macos-fixes 2021-11-30 04:15:32 +03:00
CODE_OF_CONDUCT.md Add minimal code of conduct #9676 2020-03-16 12:44:28 +03:00
CONTRIBUTING.md Remove old CLA 2021-09-28 20:16:33 +03:00
docker-compose.yml Change Docker org name 2021-09-20 01:52:21 +03:00
format_sources allow several <graphite> targets (#603) 2017-03-21 23:08:09 +04:00
LICENSE Sync copyrights 2021-10-04 09:16:18 +03:00
PreLoad.cmake Update PreLoad.cmake 2021-11-25 23:53:50 +03:00
README.md Update README.md 2021-10-12 15:38:40 +03:00
release Proper build 2021-08-24 00:09:19 +00:00
SECURITY.md Update SECURITY.md 2021-11-25 00:59:52 +03:00
uncrustify.cfg Better .clang-format and uncrustify.cfg 2018-11-29 15:45:34 +03:00

ClickHouse — open source distributed column-oriented DBMS

ClickHouse® is an open-source column-oriented database management system that allows generating analytical data reports in real-time.

  • Official website has a quick high-level overview of ClickHouse on the main page.
  • Tutorial shows how to set up and query a small ClickHouse cluster.
  • Documentation provides more in-depth information.
  • YouTube channel has a lot of content about ClickHouse in video format.
  • Slack and Telegram allow chatting with ClickHouse users in real-time.
  • Blog contains various ClickHouse-related articles, as well as announcements and reports about events.
  • Code Browser with syntax highlight and navigation.
  • Contacts can help to get your questions answered if there are any.