Coder Social home page Coder Social logo

odyssey's Introduction



Odyssey

Advanced multi-threaded PostgreSQL connection pooler and request router.

Project status

Odyssey is production-ready, it is being used in large production setups. We appreciate any kind of feedback and contribution to the project.

Coverity Scan Build Status

Design goals and main features

Multi-threaded processing

Odyssey can significantly scale processing performance by specifying a number of additional worker threads. Each worker thread is responsible for authentication and proxying client-to-server and server-to-client requests. All worker threads are sharing global server connection pools. Multi-threaded design plays important role in SSL/TLS performance.

Advanced transactional pooling

Odyssey tracks current transaction state and in case of unexpected client disconnection can emit automatic Cancel connection and do Rollback of abandoned transaction, before putting server connection back to the server pool for reuse. Additionally, last server connection owner client is remembered to reduce a need for setting up client options on each client-to-server assignment.

Better pooling control

Odyssey allows to define connection pools as a pair of Database and User. Each defined pool can have separate authentication, pooling mode and limits settings.

Authentication

Odyssey has full-featured SSL/TLS support and common authentication methods like: md5 and clear text both for client and server authentication. Odyssey supports PAM & LDAP authentication, this methods operates similarly to clear text auth except that it uses PAM/LDAP to validate user name/password pairs. PAM optionally checks the connected remote host name or IP address. Additionally it allows to block each pool user separately.

Logging

Odyssey generates universally unique identifiers uuid for client and server connections. Any log events and client error responses include the id, which then can be used to uniquely identify client and track actions. Odyssey can save log events into log file and using system logger.

CLI

Odyssey supports multiple command line options. Use /path/to/odyssey --help to see more

Architecture and internals

Odyssey has sophisticated asynchronous multi-threaded architecture which is driven by custom made coroutine engine: machinarium. Main idea behind coroutine design is to make event-driven asynchronous applications to look and feel like being written in synchronous-procedural manner instead of using traditional callback approach.

One of the main goal was to make code base understandable for new developers and to make an architecture easily extensible for future development.

More information: Architecture and internals.

Build instructions

Currently Odyssey runs only on Linux. Supported platforms are x86/x86_64.

To build you will need:

  • cmake >= 3.12.4
  • gcc >= 4.6
  • openssl
  • postgresql-server-dev-13
  • pg_config utility is in the PATH
git clone git://github.com/yandex/odyssey.git
cd odyssey
make local_build

Adapt odyssey-dev.conf then:

make local_run

Alternatively:

make console_run

Use docker environment for development (helpful for Mac users)

make start-dev-env

Set up your CLion to build project in container, manual.

Configuration reference

Service
Logging
Performance
System
Global limits
Listen
Routing
Storage
Database and user
Architecture and Internals

odyssey's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

odyssey's Issues

Out of memory

Добрый день!
Продолжаем тестировать ваш пулер.
Во время серии select only тестов pgbench пришёл oom killer:
[8821049.263349] Out of memory: Kill process 11181 (odyssey) score 966 or sacrifice child
[8821049.263537] Killed process 11181 (odyssey) total-vm:49845424kB, anon-rss:47964152kB, file-rss:0kB

Серия такая: запуск Одиссея с pool_size = 16 и workers 4. Логирование минимальное.
Дальше идёт последовательный запуск pgbench -S -T 300 с числом подключений от 100 до 1000 и шагом 50. Вот в конце последнего шага произошла данная ошибка.
Также наблюдаем снижение производительности при увеличении количества подключений.

Всё ли мы правильно настроили?
odyssey-16-4.txt

Промежуточные результаты тестирования на графиках:
1552838409 svg
1552963850 svg

gcc 8.1.0 warns about stringop overflow

[ 85%] Building C object shapito/CMakeFiles/so_library_static.dir/be_read.c.o
In function ‘shapito_be_read_options’,
    inlined from ‘shapito_be_read_startup’ at /home/rpm/odyssey/build/third_party/shapito/shapito/be_read.c:81:8:
/home/rpm/odyssey/build/third_party/shapito/shapito/be_read.c:49:32: warning: ‘__builtin_memcmp_eq’ reading 18 bytes from a region of size 17 [-Wstringop-overflow=]
   if (param->name_len == 18 && memcmp(param->data, "application_name", 18) == 0) {
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

psql: ERROR: odyssey: cc3deab3a28e8: route for 'postgres.postgres' is not found

Hello!
What am I doing wrong?
As indicated here, I launch docker-compose up.
I'm trying to connect to the databases I described, but the odyssey cannot find the routes:

[root@hl-pg-haproxy ~]# psql -p 6432 -U postgres -h 127.0.0.1 postgres
psql: ERROR:  odyssey: cc3deab3a28e8: route for 'postgres.postgres' is not found
[root@hl-pg-haproxy ~]# psql -p 6432 -U postgres -h 127.0.0.1 zabbix
psql: ERROR:  odyssey: c1cd7bb5004eb: route for 'zabbix.postgres' is not found
[root@hl-pg-haproxy ~]# psql -p 6432 -U zabbix -h 127.0.0.1 zabbix
psql: ERROR:  odyssey: cfed19a47527f: route for 'zabbix.zabbix' is not found

The full output of the docker-compose up command:

[root@hl-pg-haproxy docker]# docker-compose up
Starting docker_odyssey_1 ... done
Attaching to docker_odyssey_1
odyssey_1  | + cmake -DCMAKE_BUILD_TYPE=Debug ..
odyssey_1  | -- Use shipped libmachinarium: /odyssey/third_party/machinarium
odyssey_1  | -- Use shipped libkiwi: /odyssey/third_party/kiwi
odyssey_1  | --
odyssey_1  | -- Odyssey (version: unknown debug)
odyssey_1  | --
odyssey_1  | -- CMAKE_BUILD_TYPE:       Debug
odyssey_1  | -- BUILD_DEBIAN:           OFF
odyssey_1  | -- POSTGRESQL_INCLUDE_DIR: /usr/include/postgresql/10/server
odyssey_1  | -- POSTGRESQL_LIBRARY:     /usr/lib/x86_64-linux-gnu/libpq.a
odyssey_1  | -- USE_BORINGSSL:          OFF
odyssey_1  | -- BORINGSSL_ROOT_DIR:
odyssey_1  | -- BORINGSSL_INCLUDE_DIR:
odyssey_1  | -- OPENSSL_VERSION:        1.1.1
odyssey_1  | -- OPENSSL_ROOT_DIR:
odyssey_1  | -- OPENSSL_INCLUDE_DIR:    /usr/include
odyssey_1  | -- PAM_LIBRARY:            /usr/lib/x86_64-linux-gnu/libpam.so
odyssey_1  | -- PAM_INCLUDE_DIR:        /usr/include/security
odyssey_1  | --
odyssey_1  | -- Configuring done
odyssey_1  | -- Generating done
odyssey_1  | -- Build files have been written to: /odyssey/build
odyssey_1  | + make
odyssey_1  | [  1%] Built target libkiwi
odyssey_1  | [  2%] Built target libmachinarium
odyssey_1  | [  2%] Built target build_libs
odyssey_1  | [ 30%] Built target odyssey
odyssey_1  | [ 97%] Built target odyssey_test
odyssey_1  | [100%] Built target odyssey_stress
odyssey_1  | + ./sources/odyssey /etc/odyssey.conf
odyssey_1  | 50 18 Nov 11:12:41.944 info (startup) none Starting Odyssey
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (init) odyssey (git: unknown debug)
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (init)
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (init) using configuration file '/etc/odyssey.conf'
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (init)
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (config) daemonize            no
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (config) priority             0
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (config) unix_socket_dir      /tmp
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (config) unix_socket_mode     0644
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (config) log_format           %p %t %l [%i %s] [user - %u, db - %d] (%c) %m\n
odyssey_1  | 50 18 Nov 11:12:41.946 info [none none] [user - none, db - none] (config) log_file             /var/log/odyssey.log
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) log_to_stdout        yes
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) log_syslog           no
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) log_debug            yes
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) log_config           yes
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) log_session          yes
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) log_query            no
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) log_stats            yes
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) stats_interval       300
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) readahead            8192
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) nodelay              yes
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) keepalive            7200
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) client_max_routing   4
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) cache_msg_gc_size    0
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) cache_coroutine      0
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) coroutine_stack_size 4
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) workers              1
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) resolvers            1
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config)
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config) listen
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config)   host          *
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config)   port          6432
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config)   backlog       128
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config)   tls           disable
odyssey_1  | 50 18 Nov 11:12:41.947 info [none none] [user - none, db - none] (config)
odyssey_1  | 50 18 Nov 11:12:41.950 info [none none] [user - none, db - none] (server) listening on 0.0.0.0:6432
odyssey_1  | 50 18 Nov 11:12:41.951 info [none none] [user - none, db - none] (server) listening on [::]:6432
odyssey_1  | 50 18 Nov 11:12:52.516 info [cc3deab3a28e8 none] [user - none, db - none] (startup) new client connection 172.18.0.1:48792
odyssey_1  | 50 18 Nov 11:12:52.516 debug [cc3deab3a28e8 none] [user - none, db - none] (tls) ssl request
odyssey_1  | 50 18 Nov 11:12:52.516 debug [cc3deab3a28e8 none] [user - none, db - none] (tls) is disabled, ignoring
odyssey_1  | 50 18 Nov 11:12:52.517 error [cc3deab3a28e8 none] [user - postgres, db - postgres] (startup) route for 'postgres.postgres' is not found, closing
odyssey_1  | 50 18 Nov 11:12:54.989 info [c1cd7bb5004eb none] [user - none, db - none] (startup) new client connection 172.18.0.1:48796
odyssey_1  | 50 18 Nov 11:12:54.991 debug [c1cd7bb5004eb none] [user - none, db - none] (tls) ssl request
odyssey_1  | 50 18 Nov 11:12:54.991 debug [c1cd7bb5004eb none] [user - none, db - none] (tls) is disabled, ignoring
odyssey_1  | 50 18 Nov 11:12:54.994 error [c1cd7bb5004eb none] [user - postgres, db - zabbix] (startup) route for 'zabbix.postgres' is not found, closing
odyssey_1  | 50 18 Nov 11:12:57.413 info [cfed19a47527f none] [user - none, db - none] (startup) new client connection 172.18.0.1:48800
odyssey_1  | 50 18 Nov 11:12:57.413 debug [cfed19a47527f none] [user - none, db - none] (tls) ssl request
odyssey_1  | 50 18 Nov 11:12:57.413 debug [cfed19a47527f none] [user - none, db - none] (tls) is disabled, ignoring
odyssey_1  | 50 18 Nov 11:12:57.416 error [cfed19a47527f none] [user - zabbix, db - zabbix] (startup) route for 'zabbix.zabbix' is not found, closing

My odyssey.conf:

###
### SERVICE
###

#daemonize no
#priority -10
# pid_file "/var/run/odyssey.pid"

unix_socket_dir "/tmp"
unix_socket_mode "0644"

###
### LOGGING
###

log_file "/var/log/odyssey.log"

log_format "%p %t %l [%i %s] [user - %u, db - %d] (%c) %m\n"
log_debug yes
log_config yes
log_session yes
#log_query yes
log_stats yes

#stats_interval 60
stats_interval 300

###
### PERFORMANCE
###

#workers 1
#resolvers 1
#readahead 8192

nodelay yes
keepalive 7200

###
### GLOBAL LIMITS
###

#client_max 2000
#client_max_routing 32

###
### LISTEN
###

listen {
    tls "disable"
    host "*"
    port 6432
}

###
### ROUTING
###

storage "local" {
    type "local"
    #tls "disable"
}

database "console" {
    user odyssey {
        #authentication "none"        
        authentication "md5"
        password "odyssey"
        pool "session"
        storage "local"
    }
}

storage "postgres_server" {
    type "remote"
    tls "disable"
    host "10.51.21.65"
    port 5432
}



database "postgres" {
    user postgres {
        authentication "md5"
        password "postgres_password"
        storage "postgres_server"
        storage_user "postgres"
        storage_password "postgres_password"
        pool "session"
        client_max 4
        pool_size 0
        pool_timeout 0
        pool_ttl 60
        pool_cancel yes
        pool_discard yes
        pool_rollback yes
        client_fwd_error yes
        log_debug no
    }
}

database "zabbix" {
    user postgres {
        authentication "md5"
        password "postgres_password"
        storage "postgres_server"
        storage_user "postgres"
        storage_db "postgres"
        storage_password "postgres_password"
        pool "session"
        client_max 10
        pool_size 0
        pool_timeout 0
        pool_ttl 60
        pool_cancel yes
        pool_discard no
        pool_rollback yes
        client_fwd_error yes
        log_debug no
    }
    user zabbix {
        authentication "md5"
        password "zabbix_password"
        storage "postgres_server"
        storage_user "zabbix"
        storage_password "zabbix_password"
        pool "transaction"
        client_max 1000
        pool_size 187
        pool_timeout 0
        pool_ttl 60
        pool_cancel yes
        #pool_discard no
        pool_rollback yes
        client_fwd_error yes
        log_debug no
    }
}

Leader Failover

I'm looking into potentially deploying odyssey as a proxy for traffic from golang and I'm wondering if there's any possibility of supporting leader failover.

The issue I've hit is that both libpq and jdbc drivers support something like target_session_attrs that allow the drivers to understand leader failover.

Is this something that's possible with odyssey right now (and otherwise, what might it take to support it?)? Unfortunately, the golang driver also doesn't support this right now so I'm in something of a bind. :)

I have a question.

Hi! I am a student.Recently,I am studing odyssey.After reading the source code, I would like to ask you a question!The main role of the odysey worker thread is as follows. I don't know if it is right. The client sends a request to the console. The console sends a message type to the worker thread by creating a message channel, the worker thread matches the route, and then the route matches the database server. Finally, the database server matches the data to the worker thread through the route, and the worker thread passes. The console replies to the client. Therefore, when the number of client accesses is too large, the workload of a worker is too large, so it can be solved by adding a worker.

simple setup example?

I read the documentation and it talks about the details of the configuration, but I don't see an example setup documented. Is there one and if so, where is it?

Doesn't build on CentOS7

Trying to build on CentOS7 on dev machine getting this error.

OS Info: Linux www 3.10.0-862.2.3.el7.x86_64 # 1 SMP Wed May 9 18:05:47 UTC 2018 x86_64 x86_64 x86_64
GNU/Linux

Steps to reproduce:

  1. Download ZIP and extract.
  2. As shown below.
    [root@www odyssey-master]# pwd
    /data/sources/odyssey-master
    [root@www odyssey-master]#
    [root@www odyssey-master]#
    [root@www odyssey-master]# ls -l
    total 36
    -rw-r--r-- 1 root root   247 Jul  3 13:02 AUTHORS
    drwxr-xr-x 2 root root     6 Jul  6 15:07 build
    drwxr-xr-x 2 root root    87 Jul  3 13:02 cmake
    -rw-r--r-- 1 root root  1883 Jul  3 13:02 CMakeLists.txt
    drwxr-xr-x 3 root root    34 Jul  3 13:02 debian
    drwxr-xr-x 2 root root    88 Jul  3 13:02 documentation
    -rw-r--r-- 1 root root  1460 Jul  3 13:02 LICENSE
    -rw-r--r-- 1 root root 10552 Jul  3 13:02 odyssey.conf
    -rw-r--r-- 1 root root  7861 Jul  3 13:02 README.md
    drwxr-xr-x 5 root root    49 Jul  3 13:02 scripts
    drwxr-xr-x 2 root root  4096 Jul  3 13:02 sources
    drwxr-xr-x 2 root root    71 Jul  3 13:02 stress
    drwxr-xr-x 3 root root   108 Jul  3 13:02 test
    drwxr-xr-x 4 root root    40 Jul  3 13:02 third_party
    [root@www odyssey-master]#
    [root@www odyssey-master]# cd build/
    [root@www build]#
    [root@www build]# cmake -DCMAKE_BUILD_TYPE=Release ..
    -- The C compiler identification is GNU 4.8.5
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Looking for include file pthread.h
    -- Looking for include file pthread.h - found
    -- Looking for pthread_create
    -- Looking for pthread_create - not found
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE
    -- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found version "1.0.2k")
    -- Use shipped libmachinarium: /data/sources/odyssey-master/third_party/machinarium
    -- Use shipped libshapito: /data/sources/odyssey-master/third_party/shapito
    --
    -- Odyssey (version:  release)
    --
    -- BUILD_DEBIAN:        OFF
    -- CMAKE_BUILD_TYPE:    Release
    -- OPENSSL_VERSION:     1.0.2k
    -- OPENSSL_ROOT_DIR:
    -- OPENSSL_INCLUDE_DIR: /usr/include
    --
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /data/sources/odyssey-master/build
    [root@www build]#
    [root@www build]#
    [root@www build]# make
    Scanning dependencies of target libmachinarium
    [  1%] Generating third_party/machinarium/sources/libmachinarium.a
    -- The C compiler identification is GNU 4.8.5
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Looking for include file pthread.h
    -- Looking for include file pthread.h - found
    -- Looking for pthread_create
    -- Looking for pthread_create - not found
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE
    -- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found version "1.0.2k")
    --
    -- Machinarium: Cooperative multitasking framework.
    --
    -- BUILD_SHARED:        OFF
    -- BUILD_VALGRIND:      ON
    -- CMAKE_BUILD_TYPE:    Release
    -- OPENSSL_VERSION:     1.0.2k
    -- OPENSSL_ROOT_DIR:
    -- OPENSSL_INCLUDE_DIR: /usr/include
    --
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /data/sources/odyssey-master/build/third_party/machinarium
    Scanning dependencies of target machine_library_static
    [  3%] Building C object sources/CMakeFiles/machine_library_static.dir/thread.c.o
    [  6%] Building C object sources/CMakeFiles/machine_library_static.dir/loop.c.o
    [  9%] Building C object sources/CMakeFiles/machine_library_static.dir/clock.c.o
    [ 12%] Building C object sources/CMakeFiles/machine_library_static.dir/socket.c.o
    [ 15%] Building C object sources/CMakeFiles/machine_library_static.dir/epoll.c.o
    [ 18%] Building C object sources/CMakeFiles/machine_library_static.dir/context_stack.c.o
    [ 21%] Building C object sources/CMakeFiles/machine_library_static.dir/context.c.o
    [ 24%] Building C object sources/CMakeFiles/machine_library_static.dir/coroutine.c.o
    [ 27%] Building C object sources/CMakeFiles/machine_library_static.dir/coroutine_cache.c.o
    [ 30%] Building C object sources/CMakeFiles/machine_library_static.dir/scheduler.c.o
    [ 33%] Building C object sources/CMakeFiles/machine_library_static.dir/call.c.o
    [ 36%] Building C object sources/CMakeFiles/machine_library_static.dir/signal_mgr.c.o
    [ 39%] Building C object sources/CMakeFiles/machine_library_static.dir/event_mgr.c.o
    [ 42%] Building C object sources/CMakeFiles/machine_library_static.dir/machine.c.o
    [ 45%] Building C object sources/CMakeFiles/machine_library_static.dir/mm.c.o
    [ 48%] Building C object sources/CMakeFiles/machine_library_static.dir/machine_mgr.c.o
    [ 51%] Building C object sources/CMakeFiles/machine_library_static.dir/msg_cache.c.o
    [ 54%] Building C object sources/CMakeFiles/machine_library_static.dir/msg.c.o
    [ 57%] Building C object sources/CMakeFiles/machine_library_static.dir/channel_fast.c.o
    [ 60%] Building C object sources/CMakeFiles/machine_library_static.dir/channel.c.o
    [ 63%] Building C object sources/CMakeFiles/machine_library_static.dir/channel_api.c.o
    [ 66%] Building C object sources/CMakeFiles/machine_library_static.dir/task_mgr.c.o
    [ 69%] Building C object sources/CMakeFiles/machine_library_static.dir/tls.c.o
    [ 72%] Building C object sources/CMakeFiles/machine_library_static.dir/tls_api.c.o
    [ 75%] Building C object sources/CMakeFiles/machine_library_static.dir/io.c.o
    [ 78%] Building C object sources/CMakeFiles/machine_library_static.dir/close.c.o
    [ 81%] Building C object sources/CMakeFiles/machine_library_static.dir/connect.c.o
    [ 84%] Building C object sources/CMakeFiles/machine_library_static.dir/bind.c.o
    [ 87%] Building C object sources/CMakeFiles/machine_library_static.dir/read.c.o
    [ 90%] Building C object sources/CMakeFiles/machine_library_static.dir/read_poll.c.o
    [ 93%] Building C object sources/CMakeFiles/machine_library_static.dir/write.c.o
    [ 96%] Building C object sources/CMakeFiles/machine_library_static.dir/accept.c.o
    [100%] Building C object sources/CMakeFiles/machine_library_static.dir/dns.c.o
    Linking C static library libmachinarium.a
    [100%] Built target machine_library_static
    [  1%] Built target libmachinarium
    Scanning dependencies of target libshapito
    [  2%] Generating third_party/shapito/shapito/libshapito.a
    -- The C compiler identification is GNU 4.8.5
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    --
    -- Shapito: PostgreSQL protocol interaction library.
    --
    -- BUILD_SHARED:     OFF
    -- CMAKE_BUILD_TYPE: Release
    --
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /data/sources/odyssey-master/build/third_party/shapito
    Scanning dependencies of target so_library_static
    [ 14%] Building C object shapito/CMakeFiles/so_library_static.dir/msg.c.o
    [ 28%] Building C object shapito/CMakeFiles/so_library_static.dir/md5.c.o
    [ 42%] Building C object shapito/CMakeFiles/so_library_static.dir/password.c.o
    [ 57%] Building C object shapito/CMakeFiles/so_library_static.dir/parameter.c.o
    [ 71%] Building C object shapito/CMakeFiles/so_library_static.dir/read.c.o
    [ 85%] Building C object shapito/CMakeFiles/so_library_static.dir/be_read.c.o
    [100%] Building C object shapito/CMakeFiles/so_library_static.dir/fe_read.c.o
    Linking C static library libshapito.a
    [100%] Built target so_library_static
    [  2%] Built target libshapito
    Scanning dependencies of target build_libs
    [  2%] Built target build_libs
    Scanning dependencies of target odyssey
    [  3%] Building C object sources/CMakeFiles/odyssey.dir/pid.c.o
    [  4%] Building C object sources/CMakeFiles/odyssey.dir/daemon.c.o
    [  5%] Building C object sources/CMakeFiles/odyssey.dir/logger.c.o
    [  6%] Building C object sources/CMakeFiles/odyssey.dir/config.c.o
    [  7%] Building C object sources/CMakeFiles/odyssey.dir/config_reader.c.o
    [  8%] Building C object sources/CMakeFiles/odyssey.dir/id.c.o
    [  9%] Building C object sources/CMakeFiles/odyssey.dir/instance.c.o
    /data/sources/odyssey-master/sources/instance.c: In function ‘od_usage’:
    /data/sources/odyssey-master/sources/instance.c:85:9: error: ‘OD_VERSION_GIT’ undeclared (first use in this function)
             OD_VERSION_GIT,
             ^
    /data/sources/odyssey-master/sources/instance.c:85:9: note: each undeclared identifier is reported only once for each function it appears in
    /data/sources/odyssey-master/sources/instance.c: In function ‘od_instance_main’:
    /data/sources/odyssey-master/sources/instance.c:173:9: error: ‘OD_VERSION_GIT’ undeclared (first use in this function)
             OD_VERSION_GIT,
             ^
    make[2]: *** [sources/CMakeFiles/odyssey.dir/instance.c.o] Error 1
    make[1]: *** [sources/CMakeFiles/odyssey.dir/all] Error 2
    make: *** [all] Error 2

Using include in conf raises error 139 on docker and 134 on host

I'm trying to use include in the configuration to split the routing configuration in another file. Process starts ok with the single configuration method but if I use include it does prompt error (in docker is 139 and on host the error code is 134).

======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f109a38b7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f109a39437a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f109a39853c]
odyssey[0x40a5d9]
odyssey(od_config_reader_import+0x463)[0x40d363]
odyssey(od_instance_main+0x130)[0x4215f0]
odyssey(main+0x36)[0x406e36]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f109a334830]
odyssey(_start+0x29)[0x406e99]

Possible to kill the Odyssey Process via Telnet

It's possible to telnet into Odyssey and kill the process via Telnet

Steps to reproduce:

  • Start odyssey listening on port <port> (any config will do) odyssey myconfig
  • Telnet into odyssey telnet localhost <port>
  • Hit ctrl+c

Expected behavior:

Telnet processes ctrl+c

Actual behavior:

Odyssey process killed

Good config parameters

Hello,

assume you have a powerful machine and about 1000 clients or more.
What would be a good configuration and which parameters can harm?
Right now I can see that clients are disconnected often. Not sure if the problem is on client side or on server side.

Soe here are some settings that I modified in the odyssey config from git:

  • pool_size 300 (does it make sense to set this value to zero? Wouldn't it be the same like connecting directly to the database?)

  • workers 10 (I think that value is way to high but can it harm?)

  • resolvers 50 (Not sure what they do and what the optimal value should be)

Are there maybe some parameters that should be modified in the use case that a lot of clients are keeping the SQL connection and fetching or inserting data to the database?

Also, what would be the best way to start odyssey? Right now started it from the console.

Thanks a lot for any hint!

Odyssey does not compile on Alpine Linux

Musl libc does not implement some of the reentrant versions of drand48 that are not POSIX complaint.
This is the build log:

Scanning dependencies of target libmachinarium
Scanning dependencies of target libshapito
[  1%] Generating third_party/shapito/shapito/libshapito.a
[  2%] Generating third_party/machinarium/sources/libmachinarium.a
-- The C compiler identification is GNU 6.4.0
-- The C compiler identification is GNU 6.4.0
-- The CXX compiler identification is GNU 6.4.0
-- The CXX compiler identification is GNU 6.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Detecting CXX compile features - done
-- Looking for pthread_create
-- 
-- Shapito: PostgreSQL protocol interaction library.
-- 
-- BUILD_SHARED:     OFF
-- CMAKE_BUILD_TYPE: Release
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/odyssey/build/third_party/shapito
Scanning dependencies of target so_library_static
[ 12%] Building C object shapito/CMakeFiles/so_library_static.dir/msg.c.o
[ 25%] Building C object shapito/CMakeFiles/so_library_static.dir/parameter.c.o
[ 37%] Building C object shapito/CMakeFiles/so_library_static.dir/read.c.o
[ 62%] Building C object shapito/CMakeFiles/so_library_static.dir/password.c.o
[ 62%] Building C object shapito/CMakeFiles/so_library_static.dir/be_read.c.o
[ 75%] Building C object shapito/CMakeFiles/so_library_static.dir/md5.c.o
[ 87%] Building C object shapito/CMakeFiles/so_library_static.dir/fe_read.c.o
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Found OpenSSL: /usr/lib/libcrypto.so (found version "1.0.2o") 
-- 
-- Machinarium: Cooperative multitasking framework.
-- 
-- BUILD_SHARED:        OFF
-- BUILD_VALGRIND:      ON
-- CMAKE_BUILD_TYPE:    Release
-- OPENSSL_VERSION:     1.0.2o
-- OPENSSL_ROOT_DIR:    
-- OPENSSL_INCLUDE_DIR: /usr/include
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/odyssey/build/third_party/machinarium
Scanning dependencies of target machine_library_static
[  8%] Building C object sources/CMakeFiles/machine_library_static.dir/loop.c.o
[  8%] Building C object sources/CMakeFiles/machine_library_static.dir/thread.c.o
[  8%] Building C object sources/CMakeFiles/machine_library_static.dir/clock.c.o
[ 14%] Building C object sources/CMakeFiles/machine_library_static.dir/epoll.c.o
[ 14%] Building C object sources/CMakeFiles/machine_library_static.dir/socket.c.o
[ 17%] Building C object sources/CMakeFiles/machine_library_static.dir/context.c.o
[ 20%] Building C object sources/CMakeFiles/machine_library_static.dir/context_stack.c.o
[ 26%] Building C object sources/CMakeFiles/machine_library_static.dir/coroutine.c.o
[ 26%] Building C object sources/CMakeFiles/machine_library_static.dir/coroutine_cache.c.o
[ 29%] Building C object sources/CMakeFiles/machine_library_static.dir/scheduler.c.o
[ 32%] Building C object sources/CMakeFiles/machine_library_static.dir/call.c.o
[ 35%] Building C object sources/CMakeFiles/machine_library_static.dir/event_mgr.c.o
[ 38%] Building C object sources/CMakeFiles/machine_library_static.dir/mm.c.o
[ 41%] Building C object sources/CMakeFiles/machine_library_static.dir/machine.c.o
[ 44%] Building C object sources/CMakeFiles/machine_library_static.dir/channel_api.c.o
[ 47%] Building C object sources/CMakeFiles/machine_library_static.dir/channel.c.o
[ 50%] Building C object sources/CMakeFiles/machine_library_static.dir/channel_fast.c.o
[ 52%] Building C object sources/CMakeFiles/machine_library_static.dir/signal_mgr.c.o
[ 55%] Building C object sources/CMakeFiles/machine_library_static.dir/msg.c.o
[ 58%] Building C object sources/CMakeFiles/machine_library_static.dir/machine_mgr.c.o
[ 64%] Building C object sources/CMakeFiles/machine_library_static.dir/io.c.o
[ 64%] Building C object sources/CMakeFiles/machine_library_static.dir/tls.c.o
[ 67%] Building C object sources/CMakeFiles/machine_library_static.dir/connect.c.o
[ 79%] Building C object sources/CMakeFiles/machine_library_static.dir/msg_cache.c.o
[ 82%] Building C object sources/CMakeFiles/machine_library_static.dir/write.c.o
[ 88%] Building C object sources/CMakeFiles/machine_library_static.dir/task_mgr.c.o
[ 88%] Building C object sources/CMakeFiles/machine_library_static.dir/accept.c.o
[ 91%] Building C object sources/CMakeFiles/machine_library_static.dir/read_poll.c.o
[ 91%] Building C object sources/CMakeFiles/machine_library_static.dir/read.c.o
[ 91%] Building C object sources/CMakeFiles/machine_library_static.dir/close.c.o
[ 91%] Building C object sources/CMakeFiles/machine_library_static.dir/tls_api.c.o
[ 94%] Building C object sources/CMakeFiles/machine_library_static.dir/bind.c.o
[ 97%] Building C object sources/CMakeFiles/machine_library_static.dir/dns.c.o
[100%] Linking C static library libshapito.a
[100%] Built target so_library_static
[  2%] Built target libshapito
[100%] Linking C static library libmachinarium.a
[100%] Built target machine_library_static
[  2%] Built target libmachinarium
Scanning dependencies of target build_libs
[  2%] Built target build_libs
Scanning dependencies of target odyssey_stress
Scanning dependencies of target odyssey
Scanning dependencies of target odyssey_test
[  3%] Building C object stress/CMakeFiles/odyssey_stress.dir/odyssey_stress.c.o
[  4%] Building C object test/CMakeFiles/odyssey_test.dir/odyssey_test.c.o
[  5%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_init.c.o
[  7%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_create1.c.o
[  7%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_create0.c.o
[  8%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_config.c.o
[  9%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_context_switch.c.o
[ 10%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_sleep_yield.c.o
[ 11%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_sleep.c.o
[ 13%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_sleep_cancel0.c.o
[ 14%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_condition0.c.o
[ 15%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_join.c.o
[ 16%] Building C object sources/CMakeFiles/odyssey.dir/pid.c.o
[ 17%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_signal0.c.o
[ 18%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_condition1.c.o
[ 19%] Building C object sources/CMakeFiles/odyssey.dir/daemon.c.o
[ 20%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_signal2.c.o
[ 21%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_stat.c.o
[ 22%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_create.c.o
[ 23%] Building C object sources/CMakeFiles/odyssey.dir/config.c.o
[ 26%] Building C object sources/CMakeFiles/odyssey.dir/logger.c.o
[ 26%] Building C object sources/CMakeFiles/odyssey.dir/config_reader.c.o
[ 27%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_signal1.c.o
[ 29%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_rw0.c.o
In file included from /tmp/odyssey/sources/pid.c:16:0:
/usr/include/sys/fcntl.h:1:2: warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Wcpp]
 #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
  ^~~~~~~
[ 30%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_rw2.c.o
[ 30%] Building C object sources/CMakeFiles/odyssey.dir/id.c.o
[ 31%] Building C object sources/CMakeFiles/odyssey.dir/server_pool.c.o
[ 32%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_rw1.c.o
[ 33%] Building C object sources/CMakeFiles/odyssey.dir/client_pool.c.o
[ 34%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_rw3.c.o
[ 35%] Building C object sources/CMakeFiles/odyssey.dir/route_pool.c.o
[ 36%] Building C object sources/CMakeFiles/odyssey.dir/console.c.o
[ 41%] Building C object sources/CMakeFiles/odyssey.dir/io.c.o
[ 41%] Building C object sources/CMakeFiles/odyssey.dir/system.c.o
[ 41%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_rw4.c.o
[ 41%] Building C object sources/CMakeFiles/odyssey.dir/instance.c.o
[ 42%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_shared_rw0.c.o
[ 43%] Building C object sources/CMakeFiles/odyssey.dir/worker_pool.c.o
[ 45%] Building C object sources/CMakeFiles/odyssey.dir/router.c.o
[ 45%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_timeout.c.o
[ 46%] Building C object sources/CMakeFiles/odyssey.dir/backend.c.o
[ 47%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_cancel.c.o
In file included from /tmp/odyssey/sources/config.c:22:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
In file included from /tmp/odyssey/sources/daemon.c:16:0:
/usr/include/sys/fcntl.h:1:2: warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Wcpp]
 #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
  ^~~~~~~
[ 48%] Building C object sources/CMakeFiles/odyssey.dir/worker.c.o
In file included from /tmp/odyssey/sources/logger.c:15:0:
/usr/include/sys/fcntl.h:1:2: warning: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Wcpp]
 #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
  ^~~~~~~
[ 50%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_shared_create.c.o
[ 51%] Building C object sources/CMakeFiles/odyssey.dir/frontend.c.o
[ 52%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_shared_rw1.c.o
In file included from /tmp/odyssey/sources/logger.c:32:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
[ 53%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_channel_shared_rw2.c.o
[ 54%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_producer_consumer0.c.o
[ 55%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_producer_consumer1.c.o
[ 57%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_connect.c.o
[ 57%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_io_new.c.o
[ 58%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_connect_timeout.c.o
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:111: sources/CMakeFiles/odyssey.dir/logger.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:135: sources/CMakeFiles/odyssey.dir/config.c.o] Error 1
In file included from /tmp/odyssey/sources/config_reader.c:31:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
[ 59%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_connect_cancel0.c.o
[ 60%] Building C object sources/CMakeFiles/odyssey.dir/reset.c.o
[ 61%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_accept_timeout.c.o
[ 63%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_connect_cancel1.c.o
[ 64%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_getaddrinfo2.c.o
[ 66%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_accept_cancel.c.o
[ 66%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_getaddrinfo1.c.o
[ 67%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_getaddrinfo0.c.o
[ 68%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_client_server0.c.o
[ 69%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_client_server2.c.o
[ 70%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_client_server1.c.o
In file included from /tmp/odyssey/sources/server_pool.c:25:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
In file included from /tmp/odyssey/sources/id.c:33:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
/tmp/odyssey/sources/id.c: In function 'od_idmgr_seed':
/tmp/odyssey/sources/id.c:60:2: warning: implicit declaration of function 'srand48_r' [-Wimplicit-function-declaration]
  srand48_r(rand_seed, &mgr->rand_state);
  ^~~~~~~~~
/tmp/odyssey/sources/id.c: In function 'od_idmgr_generate':
/tmp/odyssey/sources/id.c:67:2: warning: implicit declaration of function 'lrand48_r' [-Wimplicit-function-declaration]
  lrand48_r(&mgr->rand_state, &a);
  ^~~~~~~~~
[ 71%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_10mb1.c.o
[ 72%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_10mb2.c.o
[ 73%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_cancel.c.o
[ 75%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_10mb0.c.o
[ 76%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_poll1.c.o
[ 77%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_poll0.c.o
[ 78%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_timeout.c.o
[ 79%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_poll3.c.o
[ 80%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_tls0.c.o
[ 81%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_var.c.o
[ 82%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_tls_read_10mb0.c.o
[ 83%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_read_poll2.c.o
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:159: sources/CMakeFiles/odyssey.dir/config_reader.c.o] Error 1
In file included from /tmp/odyssey/sources/route_pool.c:25:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
[ 85%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_tls_read_10mb1.c.o
[ 85%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_tls_read_var.c.o
[ 86%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_tls_read_10mb2.c.o
In file included from /tmp/odyssey/sources/instance.c:26:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
In file included from /tmp/odyssey/sources/client_pool.c:26:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
[ 89%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_tls_read_10mb_poll.c.o
[ 89%] Building C object test/CMakeFiles/odyssey_test.dir/machinarium/test_tls_read_multithread.c.o
In file included from /tmp/odyssey/sources/worker_pool.c:26:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
In file included from /tmp/odyssey/sources/worker.c:26:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
/tmp/odyssey/sources/instance.c: In function 'od_usage':
/tmp/odyssey/sources/instance.c:85:9: error: 'OD_VERSION_GIT' undeclared (first use in this function)
         OD_VERSION_GIT,
         ^~~~~~~~~~~~~~
/tmp/odyssey/sources/instance.c:85:9: note: each undeclared identifier is reported only once for each function it appears in
/tmp/odyssey/sources/instance.c: In function 'od_instance_main':
/tmp/odyssey/sources/instance.c:173:9: error: 'OD_VERSION_GIT' undeclared (first use in this function)
         OD_VERSION_GIT,
         ^~~~~~~~~~~~~~
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:231: sources/CMakeFiles/odyssey.dir/server_pool.c.o] Error 1
In file included from /tmp/odyssey/sources/io.c:24:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:183: sources/CMakeFiles/odyssey.dir/id.c.o] Error 1
In file included from /tmp/odyssey/sources/system.c:28:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
In file included from /tmp/odyssey/sources/router.c:26:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
In file included from /tmp/odyssey/sources/console.c:27:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:279: sources/CMakeFiles/odyssey.dir/route_pool.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:207: sources/CMakeFiles/odyssey.dir/instance.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:255: sources/CMakeFiles/odyssey.dir/client_pool.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:399: sources/CMakeFiles/odyssey.dir/worker.c.o] Error 1
In file included from /tmp/odyssey/sources/backend.c:26:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:423: sources/CMakeFiles/odyssey.dir/worker_pool.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:303: sources/CMakeFiles/odyssey.dir/io.c.o] Error 1
In file included from /tmp/odyssey/sources/frontend.c:26:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
In file included from /tmp/odyssey/sources/reset.c:26:0:
/tmp/odyssey/sources/id.h:25:22: error: field 'rand_state' has incomplete type
  struct drand48_data rand_state;
                      ^~~~~~~~~~
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:327: sources/CMakeFiles/odyssey.dir/system.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:351: sources/CMakeFiles/odyssey.dir/router.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:375: sources/CMakeFiles/odyssey.dir/console.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:471: sources/CMakeFiles/odyssey.dir/backend.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:495: sources/CMakeFiles/odyssey.dir/reset.c.o] Error 1
make[2]: *** [sources/CMakeFiles/odyssey.dir/build.make:447: sources/CMakeFiles/odyssey.dir/frontend.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:193: sources/CMakeFiles/odyssey.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 90%] Linking C executable odyssey_stress
[ 90%] Built target odyssey_stress
[ 91%] Linking C executable odyssey_test
[ 91%] Built target odyssey_test
make: *** [Makefile:84: all] Error 2
The command '/bin/sh -c make -j' returned a non-zero code: 2

Doesn't build on CentOS 7

Trying to build on CentOS7 on dev machine getting this error.

OS Info: Linux my2 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
GNU/Linux

cmake version 2.8.12.2
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
openssl version 1.0.2k

Postgres Pro Standard
select version()
PostgreSQL 11.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit

Steps to reproduce:

[root@my2 build]# pwd
/var/tmp/

[root@my2 tmp]# git clone git://github.com/yandex/odyssey.git
Cloning into 'odyssey'...
remote: Enumerating objects: 120, done.
remote: Counting objects: 100% (120/120), done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 11663 (delta 53), reused 51 (delta 20), pack-reused 11543
Receiving objects: 100% (11663/11663), 2.54 MiB | 338.00 KiB/s, done.
Resolving deltas: 100% (8935/8935), done.

[root@my2 tmp]# cd odyssey/

[root@my2 odyssey]# mkdir build

[root@my2 odyssey]# cd build/

[root@my2 build]# cmake -DPOSTGRESQL_LIBRARY=/opt/pgpro/std-11/lib/plpgsql.so -DPOSTGRESQL_INCLUDE_DIR=/opt/pgpro/std-11/bin/psql -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found POSTGRESQL: /opt/pgpro/std-11/lib/plpgsql.so  
-- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found version "1.0.2k") 
-- Found PAM: /usr/lib64/libpam.so  
-- Use shipped libmachinarium: /var/tmp/odyssey/third_party/machinarium
-- Use shipped libkiwi: /var/tmp/odyssey/third_party/kiwi
-- 
-- Odyssey (version: 0605a81 release)
-- 
-- CMAKE_BUILD_TYPE:       Release
-- BUILD_DEBIAN:           OFF
-- POSTGRESQL_INCLUDE_DIR: /opt/pgpro/std-11/bin/psql
-- POSTGRESQL_LIBRARY:     /opt/pgpro/std-11/lib/plpgsql.so
-- USE_BORINGSSL:          OFF
-- BORINGSSL_ROOT_DIR:     
-- BORINGSSL_INCLUDE_DIR:  
-- OPENSSL_VERSION:        1.0.2k
-- OPENSSL_ROOT_DIR:       
-- OPENSSL_INCLUDE_DIR:    /usr/include
-- PAM_LIBRARY:            /usr/lib64/libpam.so
-- PAM_INCLUDE_DIR:        /usr/include/security
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /var/tmp/odyssey/build

[root@my2 build]# make
Scanning dependencies of target libkiwi
[  1%] Generating third_party/kiwi/kiwi/libkiwi.a
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- 
-- Kiwi: PostgreSQL protocol interaction library.
-- 
-- CMAKE_BUILD_TYPE:         Release
-- MACHINARIUM_INCLUDE_DIRS: /var/tmp/odyssey/third_party/machinarium/sources
-- MACHINARIUM_LIBRARIES:    /var/tmp/odyssey/build/third_party/machinarium/sources/libmachinarium.a
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /var/tmp/odyssey/build/third_party/kiwi
Scanning dependencies of target kw_library_static
[100%] Building C object kiwi/CMakeFiles/kw_library_static.dir/md5.c.o
Linking C static library libkiwi.a
[100%] Built target kw_library_static
[  1%] Built target libkiwi
Scanning dependencies of target libmachinarium
[  2%] Generating third_party/machinarium/sources/libmachinarium.a
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found version "1.0.2k") 
-- 
-- Machinarium: Cooperative multitasking framework.
-- 
-- CMAKE_BUILD_TYPE:      Release
-- BUILD_SHARED:          OFF
-- BUILD_VALGRIND:        ON
-- USE_BORINGSSL:         OFF
-- BORINGSSL_ROOT_DIR:    
-- BORINGSSL_INCLUDE_DIR: 
-- OPENSSL_VERSION:       1.0.2k
-- OPENSSL_ROOT_DIR:      
-- OPENSSL_INCLUDE_DIR:   /usr/include
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /var/tmp/odyssey/build/third_party/machinarium
Scanning dependencies of target machine_library_static
[  2%] Building C object sources/CMakeFiles/machine_library_static.dir/thread.c.o
[  5%] Building C object sources/CMakeFiles/machine_library_static.dir/pg_rand48.c.o
[  8%] Building C object sources/CMakeFiles/machine_library_static.dir/lrand48.c.o
[ 11%] Building C object sources/CMakeFiles/machine_library_static.dir/loop.c.o
[ 13%] Building C object sources/CMakeFiles/machine_library_static.dir/clock.c.o
[ 16%] Building C object sources/CMakeFiles/machine_library_static.dir/socket.c.o
[ 19%] Building C object sources/CMakeFiles/machine_library_static.dir/epoll.c.o
[ 22%] Building C object sources/CMakeFiles/machine_library_static.dir/context_stack.c.o
[ 25%] Building C object sources/CMakeFiles/machine_library_static.dir/context.c.o
[ 27%] Building C object sources/CMakeFiles/machine_library_static.dir/coroutine.c.o
[ 30%] Building C object sources/CMakeFiles/machine_library_static.dir/coroutine_cache.c.o
[ 33%] Building C object sources/CMakeFiles/machine_library_static.dir/scheduler.c.o
[ 36%] Building C object sources/CMakeFiles/machine_library_static.dir/call.c.o
[ 38%] Building C object sources/CMakeFiles/machine_library_static.dir/signal_mgr.c.o
[ 41%] Building C object sources/CMakeFiles/machine_library_static.dir/event_mgr.c.o
[ 44%] Building C object sources/CMakeFiles/machine_library_static.dir/machine.c.o
[ 47%] Building C object sources/CMakeFiles/machine_library_static.dir/mm.c.o
[ 50%] Building C object sources/CMakeFiles/machine_library_static.dir/machine_mgr.c.o
[ 52%] Building C object sources/CMakeFiles/machine_library_static.dir/msg_cache.c.o
[ 55%] Building C object sources/CMakeFiles/machine_library_static.dir/msg.c.o
[ 58%] Building C object sources/CMakeFiles/machine_library_static.dir/channel_fast.c.o
[ 61%] Building C object sources/CMakeFiles/machine_library_static.dir/channel.c.o
[ 63%] Building C object sources/CMakeFiles/machine_library_static.dir/channel_api.c.o
[ 66%] Building C object sources/CMakeFiles/machine_library_static.dir/task_mgr.c.o
[ 69%] Building C object sources/CMakeFiles/machine_library_static.dir/tls.c.o
[ 72%] Building C object sources/CMakeFiles/machine_library_static.dir/io.c.o
[ 75%] Building C object sources/CMakeFiles/machine_library_static.dir/iov.c.o
[ 77%] Building C object sources/CMakeFiles/machine_library_static.dir/close.c.o
[ 80%] Building C object sources/CMakeFiles/machine_library_static.dir/connect.c.o
[ 83%] Building C object sources/CMakeFiles/machine_library_static.dir/bind.c.o
[ 86%] Building C object sources/CMakeFiles/machine_library_static.dir/eventfd.c.o
[ 88%] Building C object sources/CMakeFiles/machine_library_static.dir/cond.c.o
[ 91%] Building C object sources/CMakeFiles/machine_library_static.dir/read.c.o
[ 94%] Building C object sources/CMakeFiles/machine_library_static.dir/write.c.o
[ 97%] Building C object sources/CMakeFiles/machine_library_static.dir/accept.c.o
[100%] Building C object sources/CMakeFiles/machine_library_static.dir/dns.c.o
Linking C static library libmachinarium.a
[100%] Built target machine_library_static
[  2%] Built target libmachinarium
Scanning dependencies of target build_libs
[  2%] Built target build_libs
Scanning dependencies of target odyssey
[  3%] Building C object sources/CMakeFiles/odyssey.dir/daemon.c.o
cc1: warning: /opt/pgpro/std-11/bin/psql: not a directory [enabled by default]
In file included from /var/tmp/odyssey/sources/odyssey.h:34:0,
                 from /var/tmp/odyssey/sources/daemon.c:24:
/var/tmp/odyssey/sources/postgres.h:27:48: fatal error: postgresql/10/server/common/base64.h: No such file or directory
 #include <postgresql/10/server/common/base64.h>
                                                ^
compilation terminated.
make[2]: *** [sources/CMakeFiles/odyssey.dir/daemon.c.o] Error 1
make[1]: *** [sources/CMakeFiles/odyssey.dir/all] Error 2
make: *** [all] Error 2
[root@my2 build]# 


Build error on Fedora 28

Hello,

I am using Fedora 28 (not Rawhide). I tried to build odyssey project, but got compile errors:

https://pastebin.com/vcWWf54f

home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c: В функции «mm_tlsio_ctrl_cb»: /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:127:12: ошибка: dereferencing pointer to incomplete type «BIO» {aka «struct bio_st»} ret = bio->shutdown; ^~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c: На верхнем уровне: /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:147:1: ошибка: переменная «mm_tlsio_method» инициализирована, хотя имеет неполный тип static BIO_METHOD mm_tlsio_method = ^~~~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:149:3: ошибка: «BIO_METHOD» {aka «struct bio_method_st»} не содержит элемента с именем «type» .type = BIO_TYPE_MEM, ^~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:149:12: предупреждение: избыточные элементы в инициализаторе структуры .type = BIO_TYPE_MEM, ^~~~~~~~~~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:149:12: замечание: (где-то рядом с инициализацией для «mm_tlsio_method») /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:150:3: ошибка: «BIO_METHOD» {aka «struct bio_method_st»} не содержит элемента с именем «name» .name = "machinarium", ^~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:150:12: предупреждение: избыточные элементы в инициализаторе структуры .name = "machinarium", ^~~~~~~~~~~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:150:12: замечание: (где-то рядом с инициализацией для «mm_tlsio_method») /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:151:3: ошибка: «BIO_METHOD» {aka «struct bio_method_st»} не содержит элемента с именем «bwrite» .bwrite = mm_tlsio_write_cb, ^~~~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:151:12: предупреждение: избыточные элементы в инициализаторе структуры .bwrite = mm_tlsio_write_cb, ^~~~~~~~~~~~~~~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:151:12: замечание: (где-то рядом с инициализацией для «mm_tlsio_method») /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:152:3: ошибка: «BIO_METHOD» {aka «struct bio_method_st»} не содержит элемента с именем «bread» .bread = mm_tlsio_read_cb, ^~~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:152:12: предупреждение: избыточные элементы в инициализаторе структуры .bread = mm_tlsio_read_cb, ^~~~~~~~~~~~~~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:152:12: замечание: (где-то рядом с инициализацией для «mm_tlsio_method») /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:153:3: ошибка: «BIO_METHOD» {aka «struct bio_method_st»} не содержит элемента с именем «ctrl» .ctrl = mm_tlsio_ctrl_cb ^~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:153:12: предупреждение: избыточные элементы в инициализаторе структуры .ctrl = mm_tlsio_ctrl_cb ^~~~~~~~~~~~~~~~ /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:153:12: замечание: (где-то рядом с инициализацией для «mm_tlsio_method») /home/zamazan4ik/OpenSource/odyssey/build/third_party/machinarium/sources/tls_io.c:147:19: ошибка: размер «mm_tlsio_method» в памяти неизвестен static BIO_METHOD mm_tlsio_method = ^~~~~~~~~~~~~~~ gmake[5]: *** [sources/CMakeFiles/machine_library_static.dir/build.make:362: sources/CMakeFiles/machine_library_static.dir/tls_io.c.o] Ошибка 1 gmake[4]: *** [CMakeFiles/Makefile2:86: sources/CMakeFiles/machine_library_static.dir/all] Ошибка 2 gmake[3]: *** [Makefile:84: all] Ошибка 2 make[2]: *** [CMakeFiles/libmachinarium.dir/build.make:64: third_party/machinarium/sources/libmachinarium.a] Ошибка 2 make[1]: *** [CMakeFiles/Makefile2:138: CMakeFiles/libmachinarium.dir/all] Ошибка 2 make: *** [Makefile:84: all] Ошибка 2

I have used gcc 8.1.1, cmake 3.11.2, openssl-devel-1:1.1.0h-3.

My build steps are identical to provided by this repo.

I think it's about openssl-devel package version, but I am not sure.

Google Summer of Code 2019 with PostgreSQL

Hi!

How about participating in GSoC 2019?
If necessary I'm OK with co-mentoring, but we need some decent idea to be put here
https://wiki.postgresql.org/wiki/GSoC_2019
Currently, I'm not enough in context for our roadmap to generate project idea, but I can help form and apply one.

The deadline for Mentoring organizations to apply is: February 6.
The list of accepted organization will be published around February 26.

So, I think if we want it we should put a project idea in January.

CPU overhead

Привет! Спасибо за отличный продукт!

Провожу тестирование. Если количество клиентов больше чем pool_size (pool_mode: transaction), то odyssey съедает все время CPU, разрешенное в workers

Hello! Thanks for the great product!

I spend testing. If the number of clients is greater than pool_size (pool_mode: transaction), then odyssey eats up all the CPU time allowed in workers.

PAUSE and RESUME support

Hi,

Pgbouncer has special commands such as PAUSE and RESUME

PAUSE [db];
PgBouncer tries to disconnect from all servers, first waiting for all queries to complete. The command will not return before all queries are finished. To be used at the time of database restart.

If database name is given, only that database will be paused.
RESUME [db];
Resume work from previous PAUSE or SUSPEND command.

Is it possible to implement the similar commands. It allows to make postgres restart permanently for clients without their disconnection.

Set up CI

There's no CI for this repository.
Can we please set it up?

Stack size can be too small for getaddrinfo

Default stack size of 12k can leave too little space on the stack for getaddrinfo to do it's work leading to SIGSEGV on Debian stretch. Suggest making this larger, or making configurable in config file (since machinarium_set_stack_size already exists)

Allow the client to detect presence / pooling mode

Hi! This is a feature request for something that'd be nice to have, but is not currently supported by PgBouncer either... and while I have some ideas, I don't have a concrete approach in mind: just the end result.

Previously discussed in pgbouncer/pgbouncer#249, and originally in rails/rails#31190 (comment).

There are natural limitations to what the client can do with a pooled connection (particularly, when in transaction pooling mode) -- like #16.

If a client's framework/library can [efficiently*] work out that pooling is in effect on a connection, it may be able to transparently adapt (by avoiding prepared statements, say), without forcing the user to manually configure which PG features are "known broken".

* for my purposes here, I think efficiently = no more than one wasted query in the non-pooling case, and no reconnections.

Odyssey test error

When I run odyssey_test, I get an error:

machinarium_test_tls0: SSL_CTX_use_certificate_chain_file(): SSL_ERROR_SYSCALL: error:02001002:system library:fopen:No such file or directory
fail (/root/odyssey/test/machinarium/test_tls0.c:41) rc == 0
Aborted (core dumped)

No example setup instructions.

Hi,
the installation instructions are very clear and helpful, but there are no setup instructions to be found.
It would very helpful to have a basic example setup, or even any instructions on how to start/stop odyssey and use other basic functionalities.

Run Odyssey in Docker

I used the Dockerfile from #29 as base to run my own, as stated below:

FROM debian:stretch-slim as builder

WORKDIR /tmp/

RUN set -ex \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
libssl-dev \
&& git clone git://github.com/yandex/odyssey.git \
&& cd odyssey \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& make

FROM debian:stretch-slim
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends libssl-dev syslog-ng \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=builder /tmp/odyssey/build/sources/odyssey /usr/local/bin/
COPY odyssey.conf /usr/local/bin/
COPY start_odyssey.sh /usr/local/bin/
EXPOSE 6432
CMD ["/usr/local/bin/start_odyssey.sh"]

My start_odyssey.sh has only:

#!/bin/bash
# Starts odyssey
/etc/init.d/syslog-ng start
echo "Starting odyssey"
/usr/local/bin/odyssey /usr/local/bin/odyssey.conf && tail -f /var/log/odyssey.log

And I used the odyssey.conf from https://github.com/yandex/odyssey/blob/master/odyssey.conf

Official docker image

It will be very useful for beginners to give an official docker image.
It also can be used as a tutorial for installation.

core dump in transaction pooling mode

Добрый день! В процессе замеров производительности с помощью pgbench программа аварийно завершилась.
Odyssey в transaction pooling режиме. Количество клиентских соединений в pgbench указано чуть больше ограничения pool_size. Тест (видимо) любой отличный от дефолтного tpcb-like

PostgreSQL 11.2-REL_11_STABLE/dadf9814d0

В odyssey.conf сделаны два изменения:

pool "session" => pool "transaction"
pool_size 0 => pool_size 10

pgbench -c 15 test -S -T 3 -p 6432 -h localhost

Лог:

26181 11 Mar 17:21:47.401 info [none none] (init) odyssey (git: 73f4f9e release)
26181 11 Mar 17:21:47.401 info [none none] (init)
26181 11 Mar 17:21:47.401 info [none none] (init) using configuration file 'odyssey_my.conf'
26181 11 Mar 17:21:47.401 info [none none] (init)
26181 11 Mar 17:21:47.401 info [none none] (config) daemonize no
26181 11 Mar 17:21:47.401 info [none none] (config) priority 0
26181 11 Mar 17:21:47.401 info [none none] (config) unix_socket_dir /tmp
26181 11 Mar 17:21:47.401 info [none none] (config) unix_socket_mode 0644
26181 11 Mar 17:21:47.401 info [none none] (config) log_format %p %t %l [%i %s] (%c) %m\n
26181 11 Mar 17:21:47.401 info [none none] (config) log_to_stdout yes
26181 11 Mar 17:21:47.401 info [none none] (config) log_syslog no
26181 11 Mar 17:21:47.401 info [none none] (config) log_syslog_ident odyssey
26181 11 Mar 17:21:47.401 info [none none] (config) log_syslog_facility daemon
26181 11 Mar 17:21:47.401 info [none none] (config) log_debug no
26181 11 Mar 17:21:47.401 info [none none] (config) log_config yes
26181 11 Mar 17:21:47.401 info [none none] (config) log_session yes
26181 11 Mar 17:21:47.401 info [none none] (config) log_query no
26181 11 Mar 17:21:47.401 info [none none] (config) log_stats yes
26181 11 Mar 17:21:47.401 info [none none] (config) stats_interval 60
26181 11 Mar 17:21:47.401 info [none none] (config) readahead 8192
26181 11 Mar 17:21:47.401 info [none none] (config) nodelay yes
26181 11 Mar 17:21:47.401 info [none none] (config) keepalive 7200
26181 11 Mar 17:21:47.401 info [none none] (config) cache_msg_gc_size 0
26181 11 Mar 17:21:47.401 info [none none] (config) cache_coroutine 0
26181 11 Mar 17:21:47.401 info [none none] (config) coroutine_stack_size 4
26181 11 Mar 17:21:47.401 info [none none] (config) workers 1
26181 11 Mar 17:21:47.401 info [none none] (config) resolvers 1
26181 11 Mar 17:21:47.401 info [none none] (config)
26181 11 Mar 17:21:47.401 info [none none] (config) listen
26181 11 Mar 17:21:47.401 info [none none] (config) host *
26181 11 Mar 17:21:47.401 info [none none] (config) port 6432
26181 11 Mar 17:21:47.401 info [none none] (config) backlog 128
26181 11 Mar 17:21:47.401 info [none none] (config)
26181 11 Mar 17:21:47.401 info [none none] (rules) <default.default>
26181 11 Mar 17:21:47.401 info [none none] (rules) authentication none
26181 11 Mar 17:21:47.401 info [none none] (rules) pool transaction
26181 11 Mar 17:21:47.401 info [none none] (rules) pool_size 10
26181 11 Mar 17:21:47.401 info [none none] (rules) pool_timeout 0
26181 11 Mar 17:21:47.401 info [none none] (rules) pool_ttl 60
26181 11 Mar 17:21:47.401 info [none none] (rules) pool_discard no
26181 11 Mar 17:21:47.401 info [none none] (rules) pool_cancel yes
26181 11 Mar 17:21:47.401 info [none none] (rules) pool_rollback yes
26181 11 Mar 17:21:47.401 info [none none] (rules) client_fwd_error yes
26181 11 Mar 17:21:47.401 info [none none] (rules) storage postgres_server
26181 11 Mar 17:21:47.401 info [none none] (rules) type remote
26181 11 Mar 17:21:47.401 info [none none] (rules) host localhost
26181 11 Mar 17:21:47.401 info [none none] (rules) port 5432
26181 11 Mar 17:21:47.401 info [none none] (rules) log_debug no
26181 11 Mar 17:21:47.401 info [none none] (rules)
26181 11 Mar 17:21:47.404 info [none none] (server) listening on 0.0.0.0:6432
26181 11 Mar 17:21:47.404 info [none none] (server) listening on [::]:6432
26181 11 Mar 17:22:46.681 info [none none] (stats) system worker: msg (1 allocated, 0 cached, 1 freed, 0 cache_size), coroutines (5 active, 0 cached)
26181 11 Mar 17:22:46.681 info [none none] (stats) clients 0
26181 11 Mar 17:22:46.681 info [none none] (stats) worker[0]: msg (2 allocated, 0 cached, 1 freed, 0 cache_size), coroutines (5 active, 0 cached), clients_processed: 0
26181 11 Mar 17:23:07.317 info [c2f8cc345ed53 none] (startup) new client connection [::1]:49780
26181 11 Mar 17:23:07.317 info [c2f8cc345ed53 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.318 info [c2f8cc345ed53 s332b886806d6] (setup) new server connection localhost:5432 (connect time: 608 usec, resolve time: 544 usec)
26181 11 Mar 17:23:07.320 info [c2f8cc345ed53 none] (setup) login time: 3384 microseconds
26181 11 Mar 17:23:07.321 info [c2f8cc345ed53 sa13a8214eff1] (main) new server connection localhost:5432 (connect time: 349 usec, resolve time: 262 usec)
26181 11 Mar 17:23:07.342 info [c2f8cc345ed53 sa13a8214eff1] (main) client disconnected
26181 11 Mar 17:23:07.342 info [c227ee838737c none] (startup) new client connection [::1]:49786
26181 11 Mar 17:23:07.342 info [c227ee838737c none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.342 info [c227ee838737c none] (setup) login time: 208 microseconds
26181 11 Mar 17:23:07.343 info [c9b28405c8109 none] (startup) new client connection [::1]:49788
26181 11 Mar 17:23:07.343 info [c9b28405c8109 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.343 info [c9b28405c8109 none] (setup) login time: 189 microseconds
26181 11 Mar 17:23:07.343 info [c9127367f50df none] (startup) new client connection [::1]:49790
26181 11 Mar 17:23:07.343 info [c9127367f50df none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.343 info [c9127367f50df none] (setup) login time: 139 microseconds
26181 11 Mar 17:23:07.344 info [cfce2b65cf9f6 none] (startup) new client connection [::1]:49792
26181 11 Mar 17:23:07.344 info [cfce2b65cf9f6 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.344 info [cfce2b65cf9f6 none] (setup) login time: 168 microseconds
26181 11 Mar 17:23:07.344 info [cc362a057cb0e none] (startup) new client connection [::1]:49794
26181 11 Mar 17:23:07.344 info [cc362a057cb0e none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.344 info [cc362a057cb0e none] (setup) login time: 101 microseconds
26181 11 Mar 17:23:07.345 info [c8429b060eedc none] (startup) new client connection [::1]:49796
26181 11 Mar 17:23:07.345 info [c8429b060eedc none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.345 info [c8429b060eedc none] (setup) login time: 131 microseconds
26181 11 Mar 17:23:07.345 info [c31247477cad7 none] (startup) new client connection [::1]:49798
26181 11 Mar 17:23:07.345 info [c31247477cad7 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.345 info [c31247477cad7 none] (setup) login time: 98 microseconds
26181 11 Mar 17:23:07.346 info [c63b63e69f695 none] (startup) new client connection [::1]:49800
26181 11 Mar 17:23:07.346 info [c63b63e69f695 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.346 info [c63b63e69f695 none] (setup) login time: 101 microseconds
26181 11 Mar 17:23:07.346 info [c2255f17a8280 none] (startup) new client connection [::1]:49802
26181 11 Mar 17:23:07.346 info [c2255f17a8280 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.346 info [c2255f17a8280 none] (setup) login time: 99 microseconds
26181 11 Mar 17:23:07.347 info [c5bb447108ac0 none] (startup) new client connection [::1]:49804
26181 11 Mar 17:23:07.347 info [c5bb447108ac0 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.347 info [c5bb447108ac0 none] (setup) login time: 103 microseconds
26181 11 Mar 17:23:07.347 info [ce3ee0906297c none] (startup) new client connection [::1]:49806
26181 11 Mar 17:23:07.347 info [ce3ee0906297c none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.347 info [ce3ee0906297c none] (setup) login time: 100 microseconds
26181 11 Mar 17:23:07.348 info [c942db56b0667 none] (startup) new client connection [::1]:49808
26181 11 Mar 17:23:07.348 info [c942db56b0667 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.348 info [c942db56b0667 none] (setup) login time: 102 microseconds
26181 11 Mar 17:23:07.348 info [ca44f2500c367 none] (startup) new client connection [::1]:49810
26181 11 Mar 17:23:07.348 info [ca44f2500c367 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.348 info [ca44f2500c367 none] (setup) login time: 101 microseconds
26181 11 Mar 17:23:07.349 info [cfc5ca44bcde5 none] (startup) new client connection [::1]:49812
26181 11 Mar 17:23:07.349 info [cfc5ca44bcde5 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.349 info [cfc5ca44bcde5 none] (setup) login time: 112 microseconds
26181 11 Mar 17:23:07.349 info [cefc20d7419c2 none] (startup) new client connection [::1]:49814
26181 11 Mar 17:23:07.349 info [cefc20d7419c2 none] (startup) route 'test.roman' to 'default.default'
26181 11 Mar 17:23:07.349 info [cefc20d7419c2 none] (setup) login time: 101 microseconds
26181 11 Mar 17:23:07.350 info [c9b28405c8109 s586ce74f8ad1] (main) new server connection localhost:5432 (connect time: 330 usec, resolve time: 249 usec)
26181 11 Mar 17:23:07.350 info [c9127367f50df sc5d7533fc9f0] (main) new server connection localhost:5432 (connect time: 436 usec, resolve time: 353 usec)
26181 11 Mar 17:23:07.350 info [cfce2b65cf9f6 secc8e04a91bf] (main) new server connection localhost:5432 (connect time: 513 usec, resolve time: 436 usec)
26181 11 Mar 17:23:07.350 info [cc362a057cb0e s57be52777644] (main) new server connection localhost:5432 (connect time: 508 usec, resolve time: 416 usec)
26181 11 Mar 17:23:07.350 info [c8429b060eedc sc3d8b64963f2] (main) new server connection localhost:5432 (connect time: 616 usec, resolve time: 508 usec)
26181 11 Mar 17:23:07.351 info [c31247477cad7 s5e873a4f1fce] (main) new server connection localhost:5432 (connect time: 710 usec, resolve time: 616 usec)
26181 11 Mar 17:23:07.351 info [c63b63e69f695 s9c7ac15e500c] (main) new server connection localhost:5432 (connect time: 940 usec, resolve time: 710 usec)
26181 11 Mar 17:23:07.351 info [c2255f17a8280 s17bfb8658ef7] (main) new server connection localhost:5432 (connect time: 940 usec, resolve time: 710 usec)
26181 11 Mar 17:23:07.351 info [c5bb447108ac0 s715a7f77370a] (main) new server connection localhost:5432 (connect time: 1007 usec, resolve time: 919 usec)
*** Error in `./build/sources/odyssey': free(): invalid pointer: 0x00007f2090003c08 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81489)[0x7f2098374489]
./build/sources/odyssey(od_router_attach+0x113)[0x4111c3]
./build/sources/odyssey[0x423679]
./build/sources/odyssey(od_frontend+0x2112)[0x4268a2]
./build/sources/odyssey[0x4315d0]
./build/sources/odyssey[0x4323d9]
======= Memory map: ========
00400000-0043d000 r-xp 00000000 fd:00 5157276 /home/roman/git/odyssey/build/sources/odyssey
0063c000-0063d000 r--p 0003c000 fd:00 5157276 /home/roman/git/odyssey/build/sources/odyssey
0063d000-0063e000 rw-p 0003d000 fd:00 5157276 /home/roman/git/odyssey/build/sources/odyssey
00f74000-00fb7000 rw-p 00000000 00:00 0 [heap]
7f2088000000-7f2088021000 rw-p 00000000 00:00 0
7f2088021000-7f208c000000 ---p 00000000 00:00 0
7f2090000000-7f2090068000 rw-p 00000000 00:00 0
7f2090068000-7f2094000000 ---p 00000000 00:00 0
7f2096891000-7f20968a6000 r-xp 00000000 fd:00 518806 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f20968a6000-7f2096aa5000 ---p 00015000 fd:00 518806 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f2096aa5000-7f2096aa6000 r--p 00014000 fd:00 518806 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f2096aa6000-7f2096aa7000 rw-p 00015000 fd:00 518806 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f2096aa7000-7f2096ab3000 r-xp 00000000 fd:00 8739 /usr/lib64/libnss_files-2.17.so
7f2096ab3000-7f2096cb2000 ---p 0000c000 fd:00 8739 /usr/lib64/libnss_files-2.17.so
7f2096cb2000-7f2096cb3000 r--p 0000b000 fd:00 8739 /usr/lib64/libnss_files-2.17.so
7f2096cb3000-7f2096cb4000 rw-p 0000c000 fd:00 8739 /usr/lib64/libnss_files-2.17.so
7f2096cb4000-7f2096cba000 rw-p 00000000 00:00 0
7f2096cba000-7f2096d1a000 r-xp 00000000 fd:00 8877 /usr/lib64/libpcre.so.1.2.0
7f2096d1a000-7f2096f1a000 ---p 00060000 fd:00 8877 /usr/lib64/libpcre.so.1.2.0
7f2096f1a000-7f2096f1b000 r--p 00060000 fd:00 8877 /usr/lib64/libpcre.so.1.2.0
7f2096f1b000-7f2096f1c000 rw-p 00061000 fd:00 8877 /usr/lib64/libpcre.so.1.2.0
7f2096f1c000-7f2096f40000 r-xp 00000000 fd:00 8766 /usr/lib64/libselinux.so.1
7f2096f40000-7f209713f000 ---p 00024000 fd:00 8766 /usr/lib64/libselinux.so.1
7f209713f000-7f2097140000 r--p 00023000 fd:00 8766 /usr/lib64/libselinux.so.1
7f2097140000-7f2097141000 rw-p 00024000 fd:00 8766 /usr/lib64/libselinux.so.1
7f2097141000-7f2097143000 rw-p 00000000 00:00 0
7f2097143000-7f2097159000 r-xp 00000000 fd:00 8749 /usr/lib64/libresolv-2.17.so
7f2097159000-7f2097358000 ---p 00016000 fd:00 8749 /usr/lib64/libresolv-2.17.so
7f2097358000-7f2097359000 r--p 00015000 fd:00 8749 /usr/lib64/libresolv-2.17.so
7f2097359000-7f209735a000 rw-p 00016000 fd:00 8749 /usr/lib64/libresolv-2.17.so
7f209735a000-7f209735c000 rw-p 00000000 00:00 0
7f209735c000-7f209735f000 r-xp 00000000 fd:00 8909 /usr/lib64/libkeyutils.so.1.5
7f209735f000-7f209755e000 ---p 00003000 fd:00 8909 /usr/lib64/libkeyutils.so.1.5
7f209755e000-7f209755f000 r--p 00002000 fd:00 8909 /usr/lib64/libkeyutils.so.1.5
7f209755f000-7f2097560000 rw-p 00003000 fd:00 8909 /usr/lib64/libkeyutils.so.1.5
7f2097560000-7f209756e000 r-xp 00000000 fd:00 9000 /usr/lib64/libkrb5support.so.0.1
7f209756e000-7f209776e000 ---p 0000e000 fd:00 9000 /usr/lib64/libkrb5support.so.0.1
7f209776e000-7f209776f000 r--p 0000e000 fd:00 9000 /usr/lib64/libkrb5support.so.0.1
7f209776f000-7f2097770000 rw-p 0000f000 fd:00 9000 /usr/lib64/libkrb5support.so.0.1
7f2097770000-7f2097785000 r-xp 00000000 fd:00 526664 /usr/lib64/libz.so.1.2.7
7f2097785000-7f2097984000 ---p 00015000 fd:00 526664 /usr/lib64/libz.so.1.2.7
7f2097984000-7f2097985000 r--p 00014000 fd:00 526664 /usr/lib64/libz.so.1.2.7
7f2097985000-7f2097986000 rw-p 00015000 fd:00 526664 /usr/lib64/libz.so.1.2.7
7f2097986000-7f20979b7000 r-xp 00000000 fd:00 8992 /usr/lib64/libk5crypto.so.3.1
7f20979b7000-7f2097bb6000 ---p 00031000 fd:00 8992 /usr/lib64/libk5crypto.so.3.1
7f2097bb6000-7f2097bb8000 r--p 00030000 fd:00 8992 /usr/lib64/libk5crypto.so.3.1
7f2097bb8000-7f2097bb9000 rw-p 00032000 fd:00 8992 /usr/lib64/libk5crypto.so.3.1
7f2097bb9000-7f2097bbc000 r-xp 00000000 fd:00 8805 /usr/lib64/libcom_err.so.2.1
7f2097bbc000-7f2097dbb000 ---p 00003000 fd:00 8805 /usr/lib64/libcom_err.so.2.1
7f2097dbb000-7f2097dbc000 r--p 00002000 fd:00 8805 /usr/lib64/libcom_err.so.2.1
7f2097dbc000-7f2097dbd000 rw-p 00003000 fd:00 8805 /usr/lib64/libcom_err.so.2.1
7f2097dbd000-7f2097e96000 r-xp 00000000 fd:00 8998 /usr/lib64/libkrb5.so.3.3
7f2097e96000-7f2098095000 ---p 000d9000 fd:00 8998 /usr/lib64/libkrb5.so.3.3
7f2098095000-7f20980a3000 r--p 000d8000 fd:00 8998 /usr/lib64/libkrb5.so.3.3
7f20980a3000-7f20980a6000 rw-p 000e6000 fd:00 8998 /usr/lib64/libkrb5.so.3.3
7f20980a6000-7f20980f0000 r-xp 00000000 fd:00 8988 /usr/lib64/libgssapi_krb5.so.2.2
7f20980f0000-7f20982f0000 ---p 0004a000 fd:00 8988 /usr/lib64/libgssapi_krb5.so.2.2
7f20982f0000-7f20982f1000 r--p 0004a000 fd:00 8988 /usr/lib64/libgssapi_krb5.so.2.2
7f20982f1000-7f20982f3000 rw-p 0004b000 fd:00 8988 /usr/lib64/libgssapi_krb5.so.2.2
7f20982f3000-7f20984b5000 r-xp 00000000 fd:00 8721 /usr/lib64/libc-2.17.so
7f20984b5000-7f20986b5000 ---p 001c2000 fd:00 8721 /usr/lib64/libc-2.17.so
7f20986b5000-7f20986b9000 r--p 001c2000 fd:00 8721 /usr/lib64/libc-2.17.so
7f20986b9000-7f20986bb000 rw-p 001c6000 fd:00 8721 /usr/lib64/libc-2.17.soАварийный останов (core dumped)

Document the supported architecutres

As far as I understood, machinarium (and thus, oddysey) currently support only x86 and x86_64 architectures. While this is totally fine, and strict portability limitations are to be expected from any software that implements or uses coroutines, it would be helpful if this was documented somewhere, not just in the #error directive in context.c.

By the way, are there any plans for, and what is your general attitude to possible arm or mips ports?

error ... (auth) read error: Resource temporarily unavailable

Hello!

Problem:
There is no access to the public schema of another user's database. When connecting to a postgresql server without odyssey, there is access.

Users are postgres (superuser) and zabbix. The zabbix user is the owner of the zabbix database. When connecting via odyssey by postgres, you cannot read the public schema of the zabbix database.

Connect to postgresql server without odyssey:

[root@hl-pg-conpool01 ~]# psql -h 10.51.21.68 -p 5432 -U postgres -d zabbix -c "\d" | head -n 6
Password for user postgres:
                    List of relations
 Schema |            Name            |   Type   | Owner
--------+----------------------------+----------+--------
 public | acknowledges               | table    | zabbix
 public | actions                    | table    | zabbix
 public | alerts                     | table    | zabbix

Connect to postgresql server via odyssey

[root@hl-pg-conpool01 ~]# psql -h 127.0.0.1 -p 5000 -U postgres -d zabbix -c "\d" | head -n 6
Password for user postgres:
Did not find any relations.
[root@hl-pg-conpool01 ~]# psql -h 127.0.0.1 -p 5000 -U zabbix -d zabbix -c "\d" | head -n 6
Password for user zabbix: 
                    List of relations
 Schema |            Name            |   Type   | Owner  
--------+----------------------------+----------+--------
 public | acknowledges               | table    | zabbix
 public | actions                    | table    | zabbix
 public | alerts                     | table    | zabbix

At the same time, with any attempt to log in by any user in the logs, the following messages:

Dec 02 13:33:12 hl-pg-conpool01 odyssey[2487]: 2487 02 Dec 13:33:12.094 error [c8b88b95d7a0f none] [user - zabbix, db - zabbix] (auth) read error: Resource temporarily unavailable
Dec 02 13:35:50 hl-pg-conpool01 odyssey[2487]: 2487 02 Dec 13:35:50.207 error [ce4c708129718 none] [user - postgres, db - zabbix] (auth) read error: Resource temporarily unavailable
Dec 02 13:36:55 hl-pg-conpool01 odyssey[2487]: 2487 02 Dec 13:36:55.181 error [cf75fc65a5160 none] [user - zabbix, db - zabbix] (auth) read error: Resource temporarily unavailable

I use:
Centos 7.6
odyssey rpm package compiled with pgsql-11.6 (PGDG)
odyssey version:

[root@hl-pg-conpool01 odyssey]# git log -n 1
commit 95f174003117018073ab16d4c57478d19d6cab5b
Author: Dima Starkov <[email protected]>
Date:   Sun Nov 24 21:00:00 2019 +0500

    Add integration tests for SCRAM Authentication (#78)
    
    * Add integration tests for SCRAM Authentication
    
    * Made tests independent of the postgresql version

configuration file:

###
### SERVICE
###

#daemonize no
#priority -10
# pid_file "/var/run/odyssey.pid"

unix_socket_dir "/tmp"
unix_socket_mode "0644"

###
### LOGGING
###

#log_file "/var/log/odyssey.log"

log_format "%p %t %l [%i %s] [user - %u, db - %d] (%c) %m\n"
log_config yes
#log_debug yes
#log_session yes
#log_query yes
#log_stats yes
log_debug no
log_session no
log_query no
log_stats no

#stats_interval 60
stats_interval 300

###
### PERFORMANCE
###

#workers 1
#resolvers 1
readahead 8192
cache_coroutine 210

nodelay yes
keepalive 7200

###
### GLOBAL LIMITS
###

#client_max 2000
client_max_routing 32

###
### LISTEN
###

listen {
    tls "disable"
    host "*"
#    port 6432
    port 5000
}

###
### ROUTING
###

storage "local" {
    type "local"
    #tls "disable"
}

database "console" {
    user "odyssey" {
        #authentication "none"
        authentication "md5"
        password "odyssey"
        pool "session"
        storage "local"
    }
}

storage "postgres_server" {
    type "remote"
    tls "disable"
    host "10.51.21.68"
    port 5432
}

database "postgres" {
    user "postgres" {
        authentication "md5"
        password "postgres_password"
        storage "postgres_server"
        storage_user "postgres"
        storage_password "postgres_password"
        pool "session"
        client_max 4
        pool_size 0
        pool_timeout 0
        pool_ttl 60
        pool_cancel yes
        pool_discard yes
        pool_rollback yes
        client_fwd_error yes
        log_debug no
    }
}

database "zabbix" {
    user "postgres" {
        authentication "md5"
        password "postgres_password"
        storage "postgres_server"
        storage_user "postgres"
        storage_db "postgres"
        storage_password "postgres_password"
        #pool "transaction"
        pool "session"
        client_max 10
        pool_size 0
        pool_timeout 0
        pool_ttl 60
        pool_cancel yes
        #pool_discard no
        pool_discard yes
        pool_rollback yes
        client_fwd_error yes
        log_debug no
    }
    user "zabbix" {
        authentication "md5"
        password "zabbix_password"
        storage "postgres_server"
        storage_user "zabbix"
        storage_password "zabbix_password"
        #pool "transaction"
        pool "session"
        client_max 2000
        pool_size 187
        pool_timeout 0
        pool_ttl 60
        pool_cancel yes
        #pool_discard no
        pool_discard yes
        pool_rollback yes
        client_fwd_error yes
        log_debug no
    }
}

Build fails if passing custom OPENSSL_ROOT_DIR

Summary

When invoking make/ninja, the cmake generation for third party libraries is invoked without the correct environment variables (passed to initial cmake).

Suggested solution(s)

  1. Pass generated environment to subcommands (not sure if this is the "cmake way")
  2. Create all makefiles at first run
    2.1. Somehow tell cmake to do this
    2.2. Create a bash wrapper that does this
  3. ExternalProject (seems like the way to go)

Steps to reproduce

$ cmake -DOPENSSL_INCLUDE_DIR=/usr/local/opt/[email protected] -DCMAKE_BUILD_TYPE=Release -G Ninja ..
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Found OpenSSL: /usr/lib/libcrypto.dylib  
-- Use shipped libmachinarium: /Users/jbergstroem/wrk/oss/odyssey/third_party/machinarium
-- Use shipped libshapito: /Users/jbergstroem/wrk/oss/odyssey/third_party/shapito
-- 
-- Odyssey (version: 5c996e8 release)
-- 
-- CMAKE_BUILD_TYPE: Release
-- BUILD_DEBIAN:     
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jbergstroem/wrk/oss/odyssey/build

$ ninja
[1/91] Generating third_party/shapito/shapito/libshapito.a
FAILED: third_party/shapito/shapito/libshapito.a 
cd /Users/jbergstroem/wrk/oss/odyssey/build && /usr/local/Cellar/cmake/3.11.2/bin/cmake -E make_directory /Users/jbergstroem/wrk/oss/odyssey/build/third_party/shapito && /usr/local/Cellar/cmake/3.11.2/bin/cmake -E copy_directory /Users/jbergstroem/wrk/oss/odyssey/third_party/shapito /Users/jbergstroem/wrk/oss/odyssey/build/third_party/shapito && cd /Users/jbergstroem/wrk/oss/odyssey/build/third_party/shapito && /usr/local/Cellar/cmake/3.11.2/bin/cmake -DCMAKE_BUILD_TYPE=Release . && /usr/local/bin/ninja -C /Users/jbergstroem/wrk/oss/odyssey/build/third_party/shapito
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 
-- Shapito: PostgreSQL protocol interaction library.
-- 
-- BUILD_SHARED:     OFF
-- CMAKE_BUILD_TYPE: Release
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jbergstroem/wrk/oss/odyssey/build/third_party/shapito
ninja: Entering directory `/Users/jbergstroem/wrk/oss/odyssey/build/third_party/shapito'
ninja: error: loading 'build.ninja': No such file or directory
[2/91] Generating third_party/machinarium/sources/libmachinarium.a
FAILED: third_party/machinarium/sources/libmachinarium.a 
cd /Users/jbergstroem/wrk/oss/odyssey/build && /usr/local/Cellar/cmake/3.11.2/bin/cmake -E make_directory /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium && /usr/local/Cellar/cmake/3.11.2/bin/cmake -E copy_directory /Users/jbergstroem/wrk/oss/odyssey/third_party/machinarium /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium && cd /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium && /usr/local/Cellar/cmake/3.11.2/bin/cmake -DCMAKE_BUILD_TYPE=Release . && /usr/local/bin/ninja -C /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR) 
-- 
-- Machinarium: Cooperative multitasking framework.
-- 
-- BUILD_SHARED:     OFF
-- BUILD_VALGRIND:   ON
-- CMAKE_BUILD_TYPE: Release
-- 
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OPENSSL_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium
   used as include directory in directory /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium
   used as include directory in directory /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium/sources
   used as include directory in directory /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium/sources
   used as include directory in directory /Users/jbergstroem/wrk/oss/odyssey/build/third_party/machinarium/sources

-- Configuring incomplete, errors occurred!

Edit: add ExternalProject

Did you have support for the CURSOR statement ?

Pgbouncer haven't support for queries with CURSOR statement.

If the application, like django, in transaction mode setup connection add create CURSOR, next query on this CURSOR may be routed to another slave.
So, in django i should stop using cursors with DISABLE_SERVER_SIDE_CURSORS=true

Can odyssey route already used cursors to appropriate DB instance ?

Thank you for the explanation.

Build error on Ubuntu 19.04

I followed the build instructions but get the following error in the 'make' phase:

In file included from /odyssey/test/machinarium/test_sleeplock.c:3:
/odyssey/third_party/machinarium/sources/machinarium_private.h:44:10: fatal error: build.h: No such file or directory
#include "build.h"
^~~~~~~~~
compilation terminated.
make[2]: *** [test/CMakeFiles/odyssey_test.dir/build.make:427: test/CMakeFiles/odyssey_test.dir/machinarium/test_sleeplock.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:253: test/CMakeFiles/odyssey_test.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Online restart

Hi,

There is another useful pgbouncer's feature - online restart, which is implemented through cli parameter

-R
Do an online restart. That means connecting to the running process, loading the open sockets from it, and then using them. If there is no active process, boot normally. Note: Works only if OS supports Unix sockets and the unix_socket_dir is not disabled in config. Does not work on Windows machines. Does not work with TLS connections, they are dropped.

With online restart it's possible to upgrade pgbouncer with no clients downtime, so it seems it can be nice feature for Odyssey.

build fails on Ubuntu 14.04 LTS

Followed the instructions for downloading and installing:

git clone git://github.com/yandex/odyssey.git
cd odyssey
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make

The error log shows this:

/usr/bin/ld: cannot find -lpthreads

Wondering if it should be lpthread, not lpthreads...

It fails on the cmake line:

cmake -DCMAKE_BUILD_TYPE=Release ..

-- Use shipped libmachinarium: /root/odyssey/third_party/machinarium
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR)
-- Use shipped libshapito: /root/odyssey/third_party/shapito

-- Odyssey (version: f67e0b8 release)

-- CMAKE_BUILD_TYPE: Release
-- BUILD_DEBIAN: OFF

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OPENSSL_CRYPTO_LIBRARY (ADVANCED)
linked by target "odyssey" in directory /root/odyssey/sources
linked by target "odyssey_stress" in directory /root/odyssey/stress
linked by target "odyssey_test" in directory /root/odyssey/test
OPENSSL_INCLUDE_DIR (ADVANCED)
used as include directory in directory /root/odyssey
used as include directory in directory /root/odyssey
used as include directory in directory /root/odyssey
used as include directory in directory /root/odyssey/sources
used as include directory in directory /root/odyssey/stress
used as include directory in directory /root/odyssey/test
OPENSSL_SSL_LIBRARY (ADVANCED)
linked by target "odyssey" in directory /root/odyssey/sources
linked by target "odyssey_stress" in directory /root/odyssey/stress
linked by target "odyssey_test" in directory /root/odyssey/test

-- Configuring incomplete, errors occurred!
See also "/root/odyssey/build/CMakeFiles/CMakeOutput.log".
See also "/root/odyssey/build/CMakeFiles/CMakeError.log".

Tagged releases

Odyssey should tag it's releases and create a changelog.
Right now there are no tags although the product is considered beta.

Can not build on centos 7

OS info:
cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
uname -a
Linux node1-127-0-0-1 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[root@node1-127-0-0-1 build]# cmake --version
cmake version 3.15.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[root@node1-127-0-0-1 build]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@node1-127-0-0-1 opt]# git clone https://github.com/yandex/odyssey
Cloning into 'odyssey'...
remote: Enumerating objects: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 11714 (delta 14), reused 7 (delta 1), pack-reused 11669
Receiving objects: 100% (11714/11714), 2.53 MiB | 755.00 KiB/s, done.
Resolving deltas: 100% (8997/8997), done.
[root@node1-127-0-0-1 opt]# cd odyssey/

[root@node1-127-0-0-1 odyssey]# mkdir -p build
[root@node1-127-0-0-1 odyssey]# cd build/
[root@node1-127-0-0-1 build]# cd /opt/app/pg11/
bin/ include/ lib/ share/
[root@node1-127-0-0-1 build]# cd /opt/app/pg11/^C

[root@node1-127-0-0-1 build]# cmake -DPOSTGRESQL_LIBRARY=/opt/app/pg11/lib -DPOSTGRESQL_INCLUDE_DIR=/opt/app/pg11/include -DPQ_LIBRARY=/opt/app/pg11/lib -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found POSTGRESQL: /opt/app/pg11/lib
-- Found OpenSSL: /usr/lib64/libcrypto.so (found version "1.0.2k")
-- Found PAM: /usr/lib64/libpam.so
-- Use shipped libmachinarium: /opt/odyssey/third_party/machinarium
-- Use shipped libkiwi: /opt/odyssey/third_party/kiwi

-- Odyssey (version: eb72997 release)

-- CMAKE_BUILD_TYPE: Release
-- BUILD_DEBIAN: OFF
-- POSTGRESQL_INCLUDE_DIR: /opt/app/pg11/include
-- POSTGRESQL_LIBRARY: /opt/app/pg11/lib
-- PQ_LIBRARY: /opt/app/pg11/lib
-- USE_BORINGSSL: OFF
-- BORINGSSL_ROOT_DIR:
-- BORINGSSL_INCLUDE_DIR:
-- OPENSSL_VERSION: 1.0.2k
-- OPENSSL_ROOT_DIR:
-- OPENSSL_INCLUDE_DIR: /usr/include
-- PAM_LIBRARY: /usr/lib64/libpam.so
-- PAM_INCLUDE_DIR: /usr/include/security

-- Configuring done
WARNING: Target "odyssey" requests linking to directory "/opt/app/pg11/lib". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "odyssey" requests linking to directory "/opt/app/pg11/lib". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "odyssey_test" requests linking to directory "/opt/app/pg11/lib". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "odyssey_test" requests linking to directory "/opt/app/pg11/lib". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "odyssey_stress" requests linking to directory "/opt/app/pg11/lib". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "odyssey_stress" requests linking to directory "/opt/app/pg11/lib". Targets may link only to libraries. CMake is dropping the item.
-- Generating done
-- Build files have been written to: /opt/odyssey/build
[root@node1-127-0-0-1 build]# make
Scanning dependencies of target libkiwi
[ 1%] Generating third_party/kiwi/kiwi/libkiwi.a
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done

-- Kiwi: PostgreSQL protocol interaction library.

-- CMAKE_BUILD_TYPE: Release
-- MACHINARIUM_INCLUDE_DIRS: /opt/odyssey/third_party/machinarium/sources
-- MACHINARIUM_LIBRARIES: /opt/odyssey/build/third_party/machinarium/sources/libmachinarium.a

-- Configuring done
-- Generating done
-- Build files have been written to: /opt/odyssey/build/third_party/kiwi
Scanning dependencies of target kw_library_static
[ 50%] Building C object kiwi/CMakeFiles/kw_library_static.dir/md5.c.o
[100%] Linking C static library libkiwi.a
[100%] Built target kw_library_static
[ 1%] Built target libkiwi
Scanning dependencies of target libmachinarium
[ 2%] Generating third_party/machinarium/sources/libmachinarium.a
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found OpenSSL: /usr/lib64/libcrypto.so (found version "1.0.2k")

-- Machinarium: Cooperative multitasking framework.

-- CMAKE_BUILD_TYPE: Release
-- BUILD_SHARED: OFF
-- BUILD_VALGRIND: ON
-- USE_BORINGSSL: OFF
-- BORINGSSL_ROOT_DIR:
-- BORINGSSL_INCLUDE_DIR:
-- OPENSSL_VERSION: 1.0.2k
-- OPENSSL_ROOT_DIR:
-- OPENSSL_INCLUDE_DIR: /usr/include

-- Configuring done
-- Generating done
-- Build files have been written to: /opt/odyssey/build/third_party/machinarium
Scanning dependencies of target machine_library_static
[ 2%] Building C object sources/CMakeFiles/machine_library_static.dir/thread.c.o
[ 5%] Building C object sources/CMakeFiles/machine_library_static.dir/pg_rand48.c.o
[ 8%] Building C object sources/CMakeFiles/machine_library_static.dir/lrand48.c.o
[ 10%] Building C object sources/CMakeFiles/machine_library_static.dir/loop.c.o
[ 13%] Building C object sources/CMakeFiles/machine_library_static.dir/clock.c.o
/opt/odyssey/build/third_party/machinarium/sources/clock.c:64:12: warning: ‘mm_clock_list_is_sorted’ defined but not used [-Wunused-function]
static int mm_clock_list_is_sorted(mm_timer_t **list, int count)
^
[ 16%] Building C object sources/CMakeFiles/machine_library_static.dir/socket.c.o
[ 18%] Building C object sources/CMakeFiles/machine_library_static.dir/epoll.c.o
[ 21%] Building C object sources/CMakeFiles/machine_library_static.dir/context_stack.c.o
[ 24%] Building C object sources/CMakeFiles/machine_library_static.dir/context.c.o
[ 27%] Building C object sources/CMakeFiles/machine_library_static.dir/coroutine.c.o
[ 29%] Building C object sources/CMakeFiles/machine_library_static.dir/coroutine_cache.c.o
[ 32%] Building C object sources/CMakeFiles/machine_library_static.dir/scheduler.c.o
[ 35%] Building C object sources/CMakeFiles/machine_library_static.dir/call.c.o
[ 37%] Building C object sources/CMakeFiles/machine_library_static.dir/signal_mgr.c.o
[ 40%] Building C object sources/CMakeFiles/machine_library_static.dir/event_mgr.c.o
[ 43%] Building C object sources/CMakeFiles/machine_library_static.dir/machine.c.o
[ 45%] Building C object sources/CMakeFiles/machine_library_static.dir/mm.c.o
[ 48%] Building C object sources/CMakeFiles/machine_library_static.dir/machine_mgr.c.o
[ 51%] Building C object sources/CMakeFiles/machine_library_static.dir/msg_cache.c.o
[ 54%] Building C object sources/CMakeFiles/machine_library_static.dir/msg.c.o
[ 56%] Building C object sources/CMakeFiles/machine_library_static.dir/channel_fast.c.o
[ 59%] Building C object sources/CMakeFiles/machine_library_static.dir/channel.c.o
[ 62%] Building C object sources/CMakeFiles/machine_library_static.dir/channel_api.c.o
[ 64%] Building C object sources/CMakeFiles/machine_library_static.dir/task_mgr.c.o
[ 67%] Building C object sources/CMakeFiles/machine_library_static.dir/tls.c.o
[ 70%] Building C object sources/CMakeFiles/machine_library_static.dir/io.c.o
[ 72%] Building C object sources/CMakeFiles/machine_library_static.dir/iov.c.o
[ 75%] Building C object sources/CMakeFiles/machine_library_static.dir/close.c.o
[ 78%] Building C object sources/CMakeFiles/machine_library_static.dir/connect.c.o
[ 81%] Building C object sources/CMakeFiles/machine_library_static.dir/bind.c.o
[ 83%] Building C object sources/CMakeFiles/machine_library_static.dir/eventfd.c.o
[ 86%] Building C object sources/CMakeFiles/machine_library_static.dir/cond.c.o
[ 89%] Building C object sources/CMakeFiles/machine_library_static.dir/read.c.o
[ 91%] Building C object sources/CMakeFiles/machine_library_static.dir/write.c.o
[ 94%] Building C object sources/CMakeFiles/machine_library_static.dir/accept.c.o
[ 97%] Building C object sources/CMakeFiles/machine_library_static.dir/dns.c.o
[100%] Linking C static library libmachinarium.a
[100%] Built target machine_library_static
[ 2%] Built target libmachinarium
Scanning dependencies of target build_libs
[ 2%] Built target build_libs
Scanning dependencies of target odyssey
[ 3%] Building C object sources/CMakeFiles/odyssey.dir/daemon.c.o
In file included from /opt/odyssey/sources/odyssey.h:34:0,
from /opt/odyssey/sources/daemon.c:24:
/opt/odyssey/sources/postgres.h:27:27: fatal error: common/base64.h: No such file or directory
#include <common/base64.h>
^
compilation terminated.
make[2]: *** [sources/CMakeFiles/odyssey.dir/daemon.c.o] Error 1
make[1]: *** [sources/CMakeFiles/odyssey.dir/all] Error 2
make: *** [all] Error 2

error (config) route 'default.default': not defined

hello!

1. first my odyssey.conf

pid_file "/usr/local/odyssey/odyssey.pid"
log_file "/usr/local/odyssey/log/odyssey.log"
log_format "%t, %d,%u, %h:%r, %p, %l [%i %s], (%c), %m \n"
log_to_stdout yes
log_syslog no
log_syslog_ident "odyssey"
log_syslog_facility "daemon"
log_debug no
log_config yes
log_session yes
log_query yes
log_stats no
stats_interval 3
workers 2
resolvers 1
readahead 8192
pipeline 32768
cache 100
cache_chunk 0
cache_coroutine 128
nodelay yes
keepalive 7200
client_max 100

listen {
	host "*"
	port 6432
	backlog 128
}

storage "postgres_server" {
	type "remote"
	host "192.168.6.111"
	port 5432
}

database default {
	user default {
		authentication "none"
		password "postgres"
		client_max 1
		storage "postgres_server"
		pool "session"
		pool_size 2
		pool_timeout 0
		pool_ttl 60
		pool_cancel yes
		pool_rollback yes
		client_fwd_error no
		log_debug no
	}
}

storage "local" {
	type "local"
}

database "console" {
	user default {
		authentication "none"
		pool "session"
		storage "local"
	}
}

storage "db_110" {
	type "remote"
	host "192.168.6.110"
	port 5432
}

database "testdb" {
	 user default {
		authentication "none"
		password "postgres"
		client_max 1
		storage "db_110"
		storage_db "testdb"
		storage_user "readonly"
		storage_password "readonly"
		pool "session"
		pool_size 2
		pool_timeout 0
		pool_ttl 60
		pool_cancel yes
		pool_rollback yes
		client_fwd_error no
		log_debug yes
	}
}

storage "db_111" {
        type "remote"
        host "192.168.6.111"
        port 5432
}

database "test" {
         user default {
                authentication "none"
                password "postgres"
                client_max 1
                storage "db_111"
                storage_db "testdb"
                storage_user "postgres"
                storage_password "postgres"
                pool "session"
                pool_size 2
                pool_timeout 0
                pool_ttl 60
                pool_cancel yes
                pool_rollback yes
                client_fwd_error no
                log_debug yes
        }
}

2. Connect Odyssey with non-existent users or database

[postgres@zabbix_monitor ~]$ psql -h 192.168.6.111 -p 6432 -U readonly -d aa -c "select inet_server_addr(),current_database(),current_user"
 inet_server_addr | current_database | current_user 
------------------+------------------+--------------
 192.168.6.111    | postgres         | postgres
(1 row)

[postgres@zabbix_monitor ~]$ psql -h 192.168.6.111 -p 6432 -U xx -d xx -c "select inet_server_addr(),current_database(),current_user"
 inet_server_addr | current_database | current_user 
------------------+------------------+--------------
 192.168.6.111    | postgres         | postgres
(1 row)

this is my config error or Odyssey allows all connections?

3. Remove the following configuration

storage "postgres_server" {
	type "remote"
	host "192.168.6.111"
	port 5432
}

database default {
	user default {
		authentication "none"
		password "postgres"
		client_max 1
		storage "postgres_server"
		pool "session"
		pool_size 2
		pool_timeout 0
		pool_ttl 60
		pool_cancel yes
		pool_rollback yes
		client_fwd_error no
		log_debug no
	}
}

Startup reported the following error

17987 07 Jun 22:09:49.863 error (config) route 'default.default': not defined

Listening on unix socket

Hi,

Does odyssey support listeniing on Unix sockets only. We use pgbouncer currently locally on each webserver (client) which connects to pgbouncer via socket.

I checked odyssey configuration example and saw no mention of the same.

Is it a design decision or in the pipeline for future releases ?

Monitoring support and documentation

I'm looking into this project for production use, and one thing I'm not sure about is how we can get monitoring data out of this system. We currently use pgbouncer and the pgbouncer_exporter to monitor it in Prometheus.

Is there a similar level of functionality here? Would it be possible for Odyssey to expose Prometheus data directly?

Odyssey is terminating under high rate query cancellation activity

Hello!
While resolving pgbouncer "no more connections allowed (max_client_conn)" issue on low activity db we wrote some stress test prog in Golang. This prog is simply doing

  1. start query
  2. rapidly cancel query in golang context
  3. repeat it on 40 goroutine in a loop of 10000 cycles

After some time we had pgbouncer stuck in no more connections allowed (max_client_conn) and used_clients metrics from show lists over max_client_conn (=10000)

After that we want to make stress test with Odyssey to investigate its behavior under this stress tool.

To our surprise Odyssey was crashed in less than 5 seconds in session mode, and 1-10 seconds in transaction mode. pgbouncer last for 5 second in session mode and more then 5 minutes in transaction.
Below you can find our test config, some infos about os,pg and ody version, source code of our stress tool

All you need is to run stress tool and wait for Odyssey to crash:

./test_postgres --dsn "postgres://test:[email protected]:6432/test?sslmode=disable&binary_parameters=yes" -q "SELECT pg_sleep(0.02);"

in less than 5 seconds Ody will crash

Here some info before test:

root@hostname:~# ps -ef | grep ody
root     23928     1  0 23:39 ?        00:00:00 /opt/yandex/odyssey/odyssey /etc/odyssey/odyssey.conf
root     24134 23818  0 23:40 pts/0    00:00:00 grep --color=auto ody
root@hostname:~# prlimit -p 23928
RESOURCE   DESCRIPTION                             SOFT      HARD UNITS
AS         address space limit                unlimited unlimited bytes
CORE       max core file size                         0 unlimited bytes
CPU        CPU time                           unlimited unlimited seconds
DATA       max data size                      unlimited unlimited bytes
FSIZE      max file size                      unlimited unlimited bytes
LOCKS      max number of file locks held      unlimited unlimited locks
MEMLOCK    max locked-in-memory address space  16777216  16777216 bytes
MSGQUEUE   max bytes in POSIX mqueues            819200    819200 bytes
NICE       max nice prio allowed to raise             0         0
NOFILE     max number of open files               50000     50000 files
NPROC      max number of processes                 7799      7799 processes
RSS        max resident set size              unlimited unlimited bytes
RTPRIO     max real-time priority                     0         0
RTTIME     timeout for real-time tasks        unlimited unlimited microsecs
SIGPENDING max number of pending signals           7799      7799 signals
STACK      max stack size                       8388608 unlimited bytes
root@hostname:~#

Some distro info
Odyssey version: 1.0 commit 3974c0d
OS: Ubuntu 18.04 LTS,
Postgresql: Ubuntu 10.10-1.pgdg18.04+1

odyssey.conf:

daemonize yes
unix_socket_dir "/var/run/postgresql"
unix_socket_mode "0644"
log_file "/tmp/odyssey.log"
log_format "%p %t %l [%i %s] (%c) %m\n"
log_to_stdout yes
log_syslog no
log_syslog_ident "odyssey"
log_syslog_facility "daemon"
log_debug yes
log_config yes
log_session yes
log_query no
log_stats yes
stats_interval 60
workers 1
resolvers 1
readahead 8192
cache_coroutine 0
coroutine_stack_size 4
nodelay yes
keepalive 7200
listen {
	host "*"
	port 6432
	backlog 128
}
storage "postgres_server" {
	type "remote"
	
	port 5432
}
database "test"{
	 user "test"{
		authentication "md5"
		password "123456"
		client_max 10000
		storage "postgres_server"
		storage_db "postgres"
		storage_user "postgres"
		storage_password "123456"
		pool "transaction"
		pool_size 50
		pool_timeout 0
		pool_ttl 60
		pool_cancel yes
		pool_rollback yes
		client_fwd_error no
		log_debug yes
	}
}
database default {
	user default {
		authentication "block"
		storage "postgres_server"
		pool "session"
		pool_size 0
		pool_timeout 0
		pool_ttl 60
		pool_discard no
		pool_cancel yes
		pool_rollback yes
		client_fwd_error yes
		log_debug yes
	}
}
storage "local" {
	type "local"
}
database "console" {
	user default {
		authentication "none"
		pool "session"
		storage "local"
	}
}

and here is source of stress tool

main.go:

package main

import (
	"context"
	"flag"
	"fmt"

	"database/sql"
	_ "github.com/lib/pq"
	"sync"
	"time"
)

func test_db(db *sql.DB, q string) {
	ctx, _ := context.WithTimeout(context.Background(), 1*time.Millisecond)
	result, err := db.ExecContext(ctx, q)
	if err != nil {
		fmt.Println(err.Error())
		return
		//panic(err)
	}
	rows, err := result.RowsAffected()
	if err != nil {
		fmt.Println(err.Error())
		return
		//panic(err)
	}
	fmt.Println("Rows affected", rows)
}

func main() {
	var dsn = flag.String("dsn", "postgres://postgres:password@localhost:5432?sslmode=disable", "PostgreSQL DSN postgres://postgres:password@localhost:5432?sslmode=disable")
	var q = flag.String("q", "SELECT TRUE;", "Query to execute excample: \"SELECT TRUE;\"")
	flag.Parse()
	fmt.Println("Using PostgreSQL DSN:", *dsn)
	db, err := sql.Open("postgres", *dsn)
	if err != nil {
		panic(err)
	}
	defer db.Close()

	//db.SetMaxOpenConns(2000)
	//db.SetMaxIdleConns(2000)
	err = db.PingContext(context.Background())
	if err != nil {
		panic(err)
	}
	fmt.Println("Connected to BD")

	var wg sync.WaitGroup
	for e := 0; e < 40; e++ {
		wg.Add(1)
		go func() {
			for i := 0; i < 10000; i++ {
				test_db(db, *q)
			}
			wg.Done()
		}()
	}
	wg.Wait()
}

go.mod:

module ***/***/test_postgres

go 1.12

require (
	github.com/go-logfmt/logfmt v0.4.0 // indirect
	github.com/lib/pq v1.2.0
)

I hope this info will help to resolve Ody crashing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.