Implementing new option - pool_ignore_discardall#808
Implementing new option - pool_ignore_discardall#808Fenoman wants to merge 1 commit intoyandex:masterfrom
Conversation
|
Lets add the tests for this functionality, like the tests in docker/ folder |
14421cc to
9b198ec
Compare
24bed6f to
67c4414
Compare
Introduces a new pool configuration option `pool_ignore_discardall` that allows Odyssey to intercept and handle DISCARD ALL commands without forwarding them to PostgreSQL. When enabled, the pooler responds with a successful completion message while preserving packet order through sync points. This feature prevents unnecessary connection resets caused by DISCARD ALL commands from certain clients. Changes: - Add pool_ignore_discardall configuration parameter - Implement DISCARD ALL interception in frontend.c with efficient string matching - Preserve packet ordering using sync point mechanism - Add configuration parsing and logging support
67c4414 to
fbe4313
Compare
| bool match = true; | ||
|
|
||
| for (int i = 0; i < 11; ++i) | ||
| if ( (q[i] | 32) != (pat[i] | 32) ) { match = false; break; } |
There was a problem hiding this comment.
You are absolutely right—strncasecmp is an excellent and readable function. However, in this particular case, the choice to use a manual implementation for string comparison is driven, first and foremost, by considerations of extreme performance.
This code is located in the project's "hot path"—it executes for every Simple Query command that passes through the connection pool and meets the length requirement. In our specific use case, as I've mentioned before, we have quite a few microservices that explicitly and intentionally issue DISCARD ALL commands, and disabling this behavior is challenging. My reasoning was that even minimal overheads accumulate and can impact the overall request processing latency. A direct implementation of the comparison loop allows the compiler to apply aggressive optimizations (like loop unrolling) and generate highly efficient machine code, free from side effects and dependencies. Beyond pure performance, this approach has other significant advantages: portability (though perhaps less critical in our context), and predictability with simplicity (the implementation is not dependent on system locales and doesn't require including <strings.h>).
|
you need to run consider creating test for this behaviour, see https://raw.githubusercontent.com/yandex/odyssey/master/docs/development/testing.md |
Skips client-side DISCARD ALL statements instead of forwarding them to the backend (preventing it from reaching PostgreSQL).
Closes #788