Skip to content
Open
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
16 changes: 13 additions & 3 deletions src/Databases/DataLake/RestCatalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,14 +1021,15 @@ bool RestCatalog::getTableMetadataImpl(
return true;
}

void RestCatalog::sendRequest(const String & endpoint, Poco::JSON::Object::Ptr request_body, const String & method, bool ignore_result) const
void RestCatalog::sendRequest(const String & endpoint, Poco::JSON::Object::Ptr request_body, const String & method, bool ignore_result, std::optional<DB::ReadSettings> read_settings_override) const
{
std::ostringstream oss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
if (request_body)
request_body->stringify(oss);
const std::string body_str = DB::removeEscapedSlashes(oss.str());

const auto & context = getContext();
DB::ReadSettings read_settings = read_settings_override.value_or(context->getReadSettings());

DB::ReadWriteBufferFromHTTP::OutStreamCallback out_stream_callback;
if (!body_str.empty())
Expand All @@ -1050,7 +1051,7 @@ void RestCatalog::sendRequest(const String & endpoint, Poco::JSON::Object::Ptr r
auto wb = DB::BuilderRWBufferFromHTTP(url)
.withConnectionGroup(DB::HTTPConnectionGroupType::HTTP)
.withMethod(method)
.withSettings(context->getReadSettings())
.withSettings(read_settings)
.withTimeouts(DB::ConnectionTimeouts::getHTTPTimeouts(context->getSettingsRef(), context->getServerSettings()))
.withHostFilter(&context->getRemoteHostFilter())
.withHeaders(headers)
Expand Down Expand Up @@ -1085,7 +1086,16 @@ void RestCatalog::createNamespaceIfNotExists(const String & namespace_name, cons
{
ProfileEvents::increment(ProfileEvents::DataLakeRestCatalogCreateNamespace);
auto timer = DB::CurrentThread::getProfileEvents().timer(ProfileEvents::DataLakeRestCatalogCreateNamespaceMicroseconds);
sendRequest(endpoint, request_body);
DB::ReadSettings read_settings = getContext()->getReadSettings();
read_settings.http_max_tries = 1;

@subkanthi subkanthi Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldnt find a better way to stop retrying as the retries happen in sendRequest, adding to nonRetriable error codes will affect all http calls.

sendRequest(endpoint, request_body, Poco::Net::HTTPRequest::HTTP_POST, false, read_settings);
}
catch (const DB::HTTPException & e)
{
if (e.getHTTPStatus() == Poco::Net::HTTPResponse::HTTP_CONFLICT)
LOG_DEBUG(log, "Namespace {} already exists", namespace_name);
else
DB::tryLogCurrentException(log);
}
catch (...)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Databases/DataLake/RestCatalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <Databases/DataLake/ICatalog.h>
#include <Poco/Net/HTTPBasicCredentials.h>
#include <IO/ReadWriteBufferFromHTTP.h>
#include <IO/ReadSettings.h>
#include <IO/HTTPHeaderEntries.h>
#include <Interpreters/Context_fwd.h>
#include <filesystem>
Expand Down Expand Up @@ -192,7 +193,8 @@ class RestCatalog : public ICatalog, public DB::WithContext
const String & endpoint,
Poco::JSON::Object::Ptr request_body,
const String & method = Poco::Net::HTTPRequest::HTTP_POST,
bool ignore_result = false) const;
bool ignore_result = false,
std::optional<DB::ReadSettings> read_settings_override = std::nullopt) const;

std::pair<std::shared_ptr<IStorageCredentials>, String> getCredentialsAndEndpoint(Poco::JSON::Object::Ptr object, const String & location) const;

Expand Down
Loading