-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite inserting guarantees #17
Comments
Thanks for the question! I think I should add more details to the documentation.
Actually, no. ClickHouse does nothing with a query until the whole request is received. So, it's almost no difference between sending a whole Splitting the request into chunks allows using a network more efficiently because the data is being sent earlier. Yes, the kernel has a network buffer ( However, splitting leads to more syscalls (more What Note that Also, if you don't need any kind of atomicity (for instance, you're writing metrics, not business entities) you can just call
Can you provide more information here? Are you writing parallel from many tasks? 30k per second seems to be too low, what's the size of row? What's configuration of CH server and version? |
Thanks for such detailed answer! It makes more sense now
I'm writing in parallel from 3 green threads(each thread receives data over Flume async channel), rows are usually small - the biggest hitter having the following table structure
I will add more logging on my side and check what's going on with those locks, not yet sure where the "locking" occurs(don't think it's an actual deadlock) Thinking to wrap all calls to this library into |
Current writer logic is in https://github.com/let4be/crusty/blob/80a35d4168f389a925250e3be0629b10bb4166ce/main/src/clickhouse_utils.rs would be grateful if you took a brief look if I use the library correctly |
Caught it again. None of my safeguards with timeout worked, meaning it's a deadlock somewhere...
I see thousands of "socket is not connected" errors in log
|
It lagged for a while, and then I saw a bunch of errors in my logs regarding the
Do we need to properly configure those |
The error spam in clickhouse(socket is not connected) could be because we never read response body |
Yep, I decided that the default TCP keepalive should be used, but now I think that it's a bad idea (that's usually too large), I'm going to set some.
I've checked our logs and found the same errors. It's interesting, they didn't exist before, maybe some changes on another side. |
When you do not read data from the socket - it's still hanging in here and hyper uses connection pool internally, I think what really might be happening is each and every request+response permanently spoils a connection... making hyper open another one and another one while killing existing connections... |
I just did an attempted fix in my fork and it helped(tho for some reason benches did not compile, so I nuked them) - no more errors in the log yet to check if this actually fixed the other issue with hanging writers |
Unfortunately this did not resolve the original issue, - writers still appear to get locked after a while |
Though now once log is clear of non-related error spam I found this:
Those error log messages appear in clickhouse roughly at the same time I see problem with my writers |
The original issue is most likely related to system/kernel/network configuration as it appears only when I push networking stack to it's breaking point Thing is the culprit is really hard to find(or I am being blind and missing something obvious), from obvious stuff I
Yesterday I was trying changing other settings in |
I resolved the original issue... somehow I managed to configure tokio runtime("optimizing") with max_blocking_threads = 1 Configurable timeouts would be nice to have tho |
I was looking at the code and I have a question
Do we have a guarantee nothing will be send to clickhouse -before- we actually invoke
inserter.commit
?I'm doing a bunch of
inserter.write
calls and due to the way how I handle errors(backoff) there might be a situation where I accumulate quite a bunch of records and write them all withinserter.write
and only then callinserter.commit
from what I see in the code
inserter.write
actually calls this if buffer is getting bigger than some thresholdclickhouse.rs/src/insert.rs
Line 88 in cb24f41
which essentially should lead to writing into a channel(
hyper
Client'sBODY
)now if I understand correctly nothing should be sent over the wire before we actually invoke
inserter.end
/inserter.commit
(which closes the channel)am I correct in my line of thought?
It's just I am experiencing quite weird sort of bugs on high load with clickhouse where all my writers are getting locked, the throughput can get quite high(~30k writes per second) but I am writing in chunks(using infinite inserter), from several green threads to exclude possible starvation and database has been switched to memory table engine to ensure it's not IO problem
Thanks!
The text was updated successfully, but these errors were encountered: