UINT32_MAX as default timeout should not be used, because this
can lead to infinite epoll_wait in cases where there are no timers
(like gracefully shutdown of the odyssey)
Signed-off-by: rkhapov <r.khapov@ya.ru>
Co-authored-by: rkhapov <r.khapov@ya.ru>
* machinarium/channels: add get_size funcs
Can be used in some debuggin workarounds
Signed-off-by: rkhapov <r.khapov@ya.ru>
* machinarium/wait_list*
This patch adds mm_wait_list_t type
which will be used as condition variable everywhere it needed.
Ex.: wait_bus in router creates it's own wait_list, but with channels
and therefore it has memory leaks because of inconsistency of it usages.
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/route.h: fix wait_bus inconsistency
route->wait_bus was implemented with channels.
This leads to memory leaks because of inconsystency of queued
clients notifications.
This patch replaces channel with wait_list, which will not lead
to memory leaks.
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/config_reader.c: fix small memleak
just to silence asan
Signed-off-by: rkhapov <r.khapov@ya.ru>
---------
Signed-off-by: rkhapov <r.khapov@ya.ru>
Co-authored-by: rkhapov <r.khapov@ya.ru>
* sources/hba_reader.c: fix list of keywords
It must contain {0,0,0} at the end.
Signed-off-by: rkhapov <r.khapov@ya.ru>
* context.c: fix warn
This patch fixes warnings about writing function
pointer into data pointer
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/macro.h: fix warn
about signed vs unsiged comparison
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/rules.c: remove unused func
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/counter.c: fix warn
About memcpy to volatile variable
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/rules.c: fix warn
And remove useless if's
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/rules.c: remove unused var
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/console.c: remove unused vars
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/frontend.c: remove unsed var
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/rules.c: fix warns
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/backend.c: remove unused count
From functions od_backend_query*, count arg is not used
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/odyssey.h: add backend_sync
To fix warn about implicit declaration of od_backend_request_sync_point
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/address.c: fix implicit inet_pton
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/address.c: fix warn
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/clock.c: fix warn
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/rules.c: fix uninitialized var
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/frontend.c: fix warn
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/scram.c: return instead of free
goto in this place will lead to free on unitialized ptr
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/scram.c: fix warn
Case when size + 1 >= INT_MAX is extremely unlikely
Signed-off-by: rkhapov <r.khapov@ya.ru>
* test/odyssey: use test macro instead of assert
More informative + do not produce warnings
Signed-off-by: rkhapov <r.khapov@ya.ru>
* thread.c: fix warn about implicit func
Signed-off-by: rkhapov <r.khapov@ya.ru>
* docker/bin/ody-stop: SIGTERM wait
This is more useful for tests: will help to find out
if gracefully termination in odyssey doestn't work.
Signed-off-by: rkhapov <r.khapov@ya.ru>
* docker/Dockerfile: update libasan
This will possibly fix infinite DEADLYSIGNAL error
Signed-off-by: rkhapov <r.khapov@ya.ru>
* docker/entrypoint.sh: disable addr randomization
There is some bug with asan we currently using
This bug leads to infinite DEADLYSIGNAL message
on odyssey-asan runs sometimes
This patch adds some simple workaround about it
Signed-off-by: rkhapov <r.khapov@ya.ru>
* soureces/hba.c: fix reloading
It was broken, because it sets new rules list at the stack.
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/rules.c: fix router closing
It should be closed after every usage.
This patch moves closing after every logging,
otherwise there will be use-after-free.
Signed-off-by: rkhapov <r.khapov@ya.ru>
---------
Signed-off-by: rkhapov <r.khapov@ya.ru>
Co-authored-by: rkhapov <r.khapov@ya.ru>
When errno is 0, it means that client closed the connection
Signed-off-by: rkhapov <r.khapov@ya.ru>
(cherry picked from commit e4021d359980ed8e6cb86271672a0895e7aa5ae7)
Co-authored-by: rkhapov <r.khapov@ya.ru>
* machinarium: add machine_get_backtrace*
This functions will fix bugs by printing backtraces
Signed-off-by: rkhapov <rkhapov@ya.ru>
* sources/console.c: clients table improvements
1) rename 'ptr' to 'id' which is more obvious
2) replace useless 'link' with 'ptr' which can be used for debugging
3) add column 'coro' with coroutine id of the client, which can be used for debugging too
Signed-off-by: rkhapov <rkhapov@ya.ru>
---------
Signed-off-by: rkhapov <rkhapov@ya.ru>
Co-authored-by: rkhapov <rkhapov@ya.ru>
* machinarium: add advice tcp usr timeout fn
The value of tcp user timeout should be computed from keepalive values.
This patch adds advice function to machinarium for formulae of
keepalive + interval + probes - 0.5
Signed-off-by: rkhapov <r.khapov@ya.ru>
* sources/config_reader.c: use advice tcp usr timeout
Now, default value of keepalive_usr_timeout will lead to
adviced value of tcp usr timeout, computed with values of keepalive.
Signed-off-by: rkhapov <r.khapov@ya.ru>
* test_advice_keepalive_usr_timeout.c: fix milliseconds
According to `man 7 tcp`, delay and interval values are presented
seconds.
But tcp user timeout are presented in milliseconds.
So formula fixed.
Signed-off-by: rkhapov <r.khapov@ya.ru>
---------
Signed-off-by: rkhapov <r.khapov@ya.ru>
Co-authored-by: rkhapov <r.khapov@ya.ru>
There were some problems with epoll_* functions.
This is cumulative patch of fixes.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
Co-authored-by: reshke <reshke@double.cloud>
(cherry picked from commit 06ea344082e989bf30b9deced5fe0a22e9e9ea91)
Co-authored-by: reshke <reshke@double.cloud>
* machinarium/io: add mm_io_read_pending
This function will inform the caller, if there is data in mm_io_t, that
are ready for non-blocking read now.
It will be used later in od_relay_read maybe.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
* sources/relay.h: od_relay_read_pending_aware
There is a bug: when the readahead is full and there are some pending bytes
(especially for tls read-ahead case), relay->src->on_read signal will be set to 0,
and the client will be softlocked (no on_read signal with available
bytes on it).
This commit adds additional pending aware read functions, that performs
mahcine_cond_signal when there are any pending bytes.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
---------
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
Co-authored-by: Roman Khapov <r.khapov@ya.ru>
PROT_EXEC allows to execute code from coroutine stack, which is useless
feature, and moreover, this is not secure.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
Co-authored-by: Roman Khapov <r.khapov@ya.ru>
It is necessarry to invalidate frames cache after mmcoro command.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
Co-authored-by: Roman Khapov <r.khapov@ya.ru>
In mm_epoll_read_write, if arg enabled is 0, the mask of the fd is not
updated in correctly for masks with MM_R set.
It seems like there should be parentheses.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
Co-authored-by: Roman Khapov <r.khapov@ya.ru>
Now you can write mmcoro all bt, to run bt command on every coroutines.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
Co-authored-by: Roman Khapov <r.khapov@ya.ru>
* machinarium-gdb.py: fix types
It will not work on older version of gdb, so its better remove it.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
* machinarium-gdb.py: fix arch detection
selected_inferrior.architecture() doesn't work on old gdb versions.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
---------
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
Co-authored-by: Roman Khapov <r.khapov@ya.ru>
mmcoro command doesnt works for core-files.
It happens because of setting pc ans sp registers, that doesnt work in
gdb for core files.
This patchs fixes that, by using gdb's stack unwiders.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
Co-authored-by: Roman Khapov <r.khapov@ya.ru>
* third_party/mahcinarium/gdb: mm gdb support
There are many situations in odyssey that must be debugged.
But now it is really hard to do it because of machinarium coroutines engine.
This patch series will add gdb support for machinarium's
coroutines in golang's goroutines style.
For the first step command 'info mmcoros' was added, and now it
can be used to display the list of running coroutines for each thread (mm_machine).
See gdb/README.md for more.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
* machinarium-gdb.py: move out function to iterate coros
All coroutines list of the current thread will be used in the next
command, to find specified coroutine.
This commit move out function to create coroutines list out of
MMCoroutines command.
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
* machinarium-gdb.py: add mmcoro command
This command can be used to perform some gdb command
on the context of the coroutine.
It will be extremely helpful with debugging various problems in odyssey
logic.
Example:
(gdb) mmcoro 3 0 info stack
(gdb) mmcoro 3 0 frame apply 3 info locals
Signed-off-by: Roman Khapov <r.khapov@ya.ru>
* machinarium/socket: fix enable usage
Seems like it was always set to 1 by mistake.
Signed-off-by: Roman Khapov <rkhapov@yandex-team.ru>
* sources/sighandler.c: fix SIGPIPE ignoring
Seems like it was added into mask but not in ignore_mask by mistake.
This patchs will not change any behaviour because now there is no
SIGPIPE section in switch, which handles signals in oddyssey machine.
Signed-off-by: Roman Khapov <rkhapov@yandex-team.ru>
* tests/oddyssey_test.c: add SIGPIPE ignoring
For now, tests doesn't have SIGPIPE ignoring.
This will lead to flaky behaviour for some tests (like tls unix socket),
because of the race for reading messages from closed socket.
This patch adds some new tests for closed socket reading and adds
SIGPIPE ignoring for odyssey_test.c
Signed-off-by: Roman Khapov <rkhapov@yandex-team.ru>
---------
Signed-off-by: Roman Khapov <rkhapov@yandex-team.ru>
* all infinite loops to for(;;)
* error in word
* change kebab case in test folders in snake case
* now for test ip6 use ip6-localhost for ip4 use ip4-localhost
* malloc restyle for easier finding allocation of structures
* lint
* Solved the problem for packet sequence mismatch for packet
* Corrected the forwarding for all types of packet
* Added the formating
* Changed formating
* Added clang format
* Changed format
Co-authored-by: janand <janand@yugabyte.com>
* Target session attr feature for storage
Storage host section is now accepts a comma-separated
PostgreSQL hosts list, in format "host2,host2"
or "[host1]:port1,host2" etc.
Storage structure now holds pointer to host, which connection was acquired.
This is required to cancel`s queries to work fine.
Target session attrs policies added:
read-write
read-only
any (default)
Target session attrs uses pg_is_in_recovery function to
check if host in primary or replica. in_hot_standby option is not checked yet.
FIx a typo. Advanced PGOPTIONS parsing was added between
1.1 and 1.2 odyssey versions, including idle_in_transaction_session_timeout
parameter passing. Thats means odyssey will lookup in startup parameter
key/value pairs and parse all hardcoded pgoptions, but this require full match
between hardcoded pgoption name and startup key
* Fix unnamed prepared statement polling
* Send on read signal if ssl readahead is not exhaused
* remote null byte from snprintf
Co-authored-by: Kirill Reshke <reshke@yandex-team.ru>
* Move auth query server querying logic to separate file
* Refactor query code to support not only "auth_query" like queries
* Move storage logic to separate file & add storage watchdog
* Force several settings on starts
* Fix simple query parsing
* Fixed bugs
* Fix config reload
* Add tests
* Move cathcup logic to separate func
* Fix tests[2]
Co-authored-by: Andrey Borodin <amborodin@acm.org>