-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Send a X-ClickHouse summary on the header for HTTP client with number of rows inserted #5116
Send a X-ClickHouse summary on the header for HTTP client with number of rows inserted #5116
Conversation
It does not work:
|
dbms/src/IO/Progress.cpp
Outdated
} | ||
|
||
|
||
void AllProgressValueImpl::write(const ProgressValues & value, WriteBuffer & out, UInt64 /*client_revision*/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backward compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backward compatibility yes. First different implementation were made of this helpers because compared about how we count the read rows, it's not really on real time but only in the end of query. So it wouldn't made that much sense at the moment that we show this value during the progress.
So AllProgressValueImpl has been implemented as a default case as it's quite likely the one would need to use. While the other implementation (concerning the read and write progress), is quite a specific case as it's used when a client use an HTTP request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait I just think of, do you talk about backward compatibility with new version of database and old client ? this PR don't handle this case right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we maintain compatibility between server and client (including drivers with native protocol) in both ways: old client with new server and new client with old server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks, now it's fixed. I will just need to probably need to modify the file Define.h
before the code got merged if we got an another release
Thanks for the feedback, does it's possible to have more information about how you were able to produce the bugs ? Tried to do a simple test and wasn't able to reproduce it :/ |
I did not done it manually, just clicked to "Details" link near the checks, then clicked to relevant logs. |
Thanks ! Now both problems are resolved. We can use now a client or a server with an outdated version without any problem, the segfault is normally resolved as well |
write_* -> written_* ? |
@@ -80,6 +80,11 @@ class WriteBufferFromHTTPServerResponse : public BufferWithOwnMemory<WriteBuffer | |||
/// but not finish them with \r\n, allowing to send more headers subsequently. | |||
void startSendHeaders(); | |||
|
|||
// Used for write the header X-ClickHouse-progress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading comment. We have X-ClickHouse-Progress (capital P)
@@ -80,6 +80,11 @@ class WriteBufferFromHTTPServerResponse : public BufferWithOwnMemory<WriteBuffer | |||
/// but not finish them with \r\n, allowing to send more headers subsequently. | |||
void startSendHeaders(); | |||
|
|||
// Used for write the header X-ClickHouse-progress | |||
void writeHeaderProgress(); | |||
// Used for write the header X-ClickHouse-summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
X-ClickHouse-Summary
dbms/src/IO/Progress.h
Outdated
void ProgressValues::writeJSON(WriteBuffer & out) const | ||
{ | ||
WriteJSONImpl::writeJSON(*this, out); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks awkwardly structured for me.
dbms/src/IO/Progress.h
Outdated
}; | ||
|
||
struct AllProgressValueImpl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lack of comments. (but first need to think how to rewrite this code...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's both ReadProgress and WriteProgress have read, write, writeJSON methods.
But better to rename read -> deserializeBinary, write -> serializeBinary, writeJSON -> serializeJSON for clarity.
And let's rename AllProgress to ReadWriteProgress.
And let's ReadWriteProgress has ReadProgress and WriteProgress as its members. And its serde methods will take revision as an argument and call child methods appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
In this example, the |
WriteBufferFromOwnString progress_string_writer; | ||
accumulated_progress.writeJSON<ReadProgressValueImpl>(progress_string_writer); | ||
|
||
#if defined(POCO_CLICKHOUSE_PATCH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move it few lines above?
Ok thanks ! The changes were applied, Just two notes :
|
dbms/src/IO/Progress.h
Outdated
|
||
void read(ReadBuffer & in, UInt64 server_revision); | ||
void write(WriteBuffer & out, UInt64 client_revision) const; | ||
void writeJSON(WriteBuffer & out) const; | ||
}; | ||
|
||
struct ReadProgress | ||
{ | ||
size_t rows; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also rename here and above for consistency: read_rows, read_bytes, total_rows_to_read.
dbms/src/IO/Progress.h
Outdated
/// See Progress. | ||
struct ProgressValues | ||
{ | ||
size_t rows; | ||
size_t bytes; | ||
size_t total_rows; | ||
size_t write_rows; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably written
will be better than write
?
|
Why? |
One of the reason about why it's that sometime, it's seem during Like on the example I write in the beginning of the PR, with the argument While when I use a smaller set of data, like with this command line :
We got more header who are send to the client with the value read_rows and read_bytes with value > 0. So I don't know it was a bug or not but the main reason was to have first a first version who is consistent in term of results. While to have other fix who incorporate the changes with a real time progress, but also an integration with the TCP client. |
Now it is Ok. PS. Let's not forget to mention it as backward incompatible change in changelog. |
Excuse me, is it currently possible by any means (via http protocol) to get the information on how many rows were returned by the query? |
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
For changelog. Remove if this is non-significant change.
Category (leave one):
Short description (up to few sentences):
Add a X-ClickHouse-Summary header when we send a query using HTTP with the settings
send_progress_in_http_headers
is enabled. Return the usual information of X-ClickHouse-Progress, with additional information like how many rows and bytes were inserted in the query.Detailed description (optional):
link to #2825