Skip to content
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

Cherry pick #55336 to 23.8: Review #51946 and partially revert it #55404

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
803 changes: 0 additions & 803 deletions docs/en/interfaces/http.md

This file was deleted.

648 changes: 0 additions & 648 deletions docs/ru/interfaces/http.md

This file was deleted.

639 changes: 0 additions & 639 deletions docs/zh/interfaces/http.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/Common/ProgressIndication.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct ThreadEventData
UInt64 system_ms = 0;
UInt64 memory_usage = 0;

// -1 used as flag 'is not show for old servers'
// -1 used as flag 'is not shown for old servers'
Int64 peak_memory_usage = -1;
};

Expand Down
12 changes: 5 additions & 7 deletions src/IO/Progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ void ProgressValues::write(WriteBuffer & out, UInt64 client_revision) const
}
}

void ProgressValues::writeJSON(WriteBuffer & out, bool add_braces) const
void ProgressValues::writeJSON(WriteBuffer & out) const
{
/// Numbers are written in double quotes (as strings) to avoid loss of precision
/// of 64-bit integers after interpretation by JavaScript.

if (add_braces)
writeCString("{", out);
writeCString("{", out);
writeCString("\"read_rows\":\"", out);
writeText(read_rows, out);
writeCString("\",\"read_bytes\":\"", out);
Expand All @@ -93,8 +92,7 @@ void ProgressValues::writeJSON(WriteBuffer & out, bool add_braces) const
writeCString("\",\"elapsed_ns\":\"", out);
writeText(elapsed_ns, out);
writeCString("\"", out);
if (add_braces)
writeCString("}", out);
writeCString("}", out);
}

bool Progress::incrementPiecewiseAtomically(const Progress & rhs)
Expand Down Expand Up @@ -236,9 +234,9 @@ void Progress::write(WriteBuffer & out, UInt64 client_revision) const
getValues().write(out, client_revision);
}

void Progress::writeJSON(WriteBuffer & out, bool add_braces) const
void Progress::writeJSON(WriteBuffer & out) const
{
getValues().writeJSON(out, add_braces);
getValues().writeJSON(out);
}

void Progress::incrementElapsedNs(UInt64 elapsed_ns_)
Expand Down
4 changes: 2 additions & 2 deletions src/IO/Progress.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct ProgressValues

void read(ReadBuffer & in, UInt64 server_revision);
void write(WriteBuffer & out, UInt64 client_revision) const;
void writeJSON(WriteBuffer & out, bool add_braces = true) const;
void writeJSON(WriteBuffer & out) const;
};

struct ReadProgress
Expand Down Expand Up @@ -119,7 +119,7 @@ struct Progress
void write(WriteBuffer & out, UInt64 client_revision) const;

/// Progress in JSON format (single line, without whitespaces) is used in HTTP headers.
void writeJSON(WriteBuffer & out, bool add_braces = true) const;
void writeJSON(WriteBuffer & out) const;

/// Each value separately is changed atomically (but not whole object).
bool incrementPiecewiseAtomically(const Progress & rhs);
Expand Down
9 changes: 2 additions & 7 deletions src/Server/HTTP/WriteBufferFromHTTPServerResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ void WriteBufferFromHTTPServerResponse::writeHeaderProgressImpl(const char * hea

WriteBufferFromOwnString progress_string_writer;

writeCString("{", progress_string_writer);
accumulated_progress.writeJSON(progress_string_writer, false);
writeCString(",\"peak_memory_usage\":\"", progress_string_writer);
writeText(peak_memory_usage, progress_string_writer);
writeCString("\"}", progress_string_writer);
accumulated_progress.writeJSON(progress_string_writer);

if (response_header_ostr)
*response_header_ostr << header_name << progress_string_writer.str() << "\r\n" << std::flush;
Expand Down Expand Up @@ -153,7 +149,7 @@ WriteBufferFromHTTPServerResponse::WriteBufferFromHTTPServerResponse(
}


void WriteBufferFromHTTPServerResponse::onProgress(const Progress & progress, Int64 peak_memory_usage_)
void WriteBufferFromHTTPServerResponse::onProgress(const Progress & progress)
{
std::lock_guard lock(mutex);

Expand All @@ -162,7 +158,6 @@ void WriteBufferFromHTTPServerResponse::onProgress(const Progress & progress, In
return;

accumulated_progress.incrementPiecewiseAtomically(progress);
peak_memory_usage = peak_memory_usage_;
if (send_progress && progress_watch.elapsed() >= send_progress_interval_ms * 1000000)
{
accumulated_progress.incrementElapsedNs(progress_watch.elapsed());
Expand Down
12 changes: 5 additions & 7 deletions src/Server/HTTP/WriteBufferFromHTTPServerResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class WriteBufferFromHTTPServerResponse final : public BufferWithOwnMemory<Write
~WriteBufferFromHTTPServerResponse() override;

/// Writes progress in repeating HTTP headers.
void onProgress(const Progress & progress, Int64 peak_memory_usage_);
void onProgress(const Progress & progress);

/// Turn compression on or off.
/// The setting has any effect only if HTTP headers haven't been sent yet.
Expand Down Expand Up @@ -89,13 +89,13 @@ class WriteBufferFromHTTPServerResponse final : public BufferWithOwnMemory<Write
/// but not finish them with \r\n, allowing to send more headers subsequently.
void startSendHeaders();

// Used for write the header X-ClickHouse-Progress / X-ClickHouse-Summary
/// Used to write the header X-ClickHouse-Progress / X-ClickHouse-Summary
void writeHeaderProgressImpl(const char * header_name);
// Used for write the header X-ClickHouse-Progress
/// Used to write the header X-ClickHouse-Progress
void writeHeaderProgress();
// Used for write the header X-ClickHouse-Summary
/// Used to write the header X-ClickHouse-Summary
void writeHeaderSummary();
// Use to write the header X-ClickHouse-Exception-Code even when progress has been sent
/// Use to write the header X-ClickHouse-Exception-Code even when progress has been sent
void writeExceptionCode();

/// This method finish headers with \r\n, allowing to start to send body.
Expand Down Expand Up @@ -128,8 +128,6 @@ class WriteBufferFromHTTPServerResponse final : public BufferWithOwnMemory<Write

int exception_code = 0;

Int64 peak_memory_usage = 0;

std::mutex mutex; /// progress callback could be called from different threads.
};

Expand Down
3 changes: 1 addition & 2 deletions src/Server/HTTPHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,7 @@ void HTTPHandler::processQuery(
/// Note that we add it unconditionally so the progress is available for `X-ClickHouse-Summary`
append_callback([&used_output](const Progress & progress)
{
const auto& thread_group = CurrentThread::getGroup();
used_output.out->onProgress(progress, thread_group->memory_tracker.getPeak());
used_output.out->onProgress(progress);
});

if (settings.readonly > 0 && settings.cancel_http_readonly_queries_on_client_close)
Expand Down