From d1af1422e7a810ddfd31342bbc1d3e15fd68e7d4 Mon Sep 17 00:00:00 2001 From: sfc-gh-vreddy <66025379+sfc-gh-vreddy@users.noreply.github.com> Date: Mon, 29 Jun 2020 12:40:28 -0700 Subject: [PATCH] SNOW 162610: Do not use thread pool when parallel=1 (#213) * Do not use thread pool when parallel=1 * Version bump to test with ODBC driver Co-authored-by: Harry Xi --- cpp/FileTransferAgent.cpp | 48 +++++++++++++++++++++++++++++++++++++ include/snowflake/version.h | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/cpp/FileTransferAgent.cpp b/cpp/FileTransferAgent.cpp index 9fa0509f6f..85114a8388 100755 --- a/cpp/FileTransferAgent.cpp +++ b/cpp/FileTransferAgent.cpp @@ -248,6 +248,30 @@ void Snowflake::Client::FileTransferAgent::uploadFilesInParallel(std::string *co FileMetadata * metadata = &m_smallFilesMeta[i]; m_executionResults->SetFileMetadata(&m_smallFilesMeta[i], resultIndex); metadata->overWrite = response.overwrite; + + // workaround for incident 00212627 + // Do not use thread pool when parallel = 1 + if ((unsigned int)response.parallel <= 1) + { + do + { + RemoteStorageRequestOutcome outcome = uploadSingleFile(m_storageClient, metadata, + resultIndex); + if (outcome == RemoteStorageRequestOutcome::TOKEN_EXPIRED) + { + _mutex_lock(&m_parallelTokRenewMutex); + this->renewToken(command); + _mutex_unlock(&m_parallelTokRenewMutex); + } + else + { + break; + } + } while (true); + + continue; + } + tp.AddJob([metadata, resultIndex, command, this]()->void { do { @@ -482,6 +506,30 @@ void Snowflake::Client::FileTransferAgent::downloadFilesInParallel(std::string * size_t resultIndex = i + m_largeFilesMeta.size(); FileMetadata * metadata = &m_smallFilesMeta[i]; m_executionResults->SetFileMetadata(&m_smallFilesMeta[i], resultIndex); + + // workaround for incident 00212627 + // Do not use thread pool when parallel = 1 + if ((unsigned int)response.parallel <= 1) + { + do + { + RemoteStorageRequestOutcome outcome = downloadSingleFile(m_storageClient, metadata, + resultIndex); + if (outcome == RemoteStorageRequestOutcome::TOKEN_EXPIRED) + { + _mutex_lock(&m_parallelTokRenewMutex); + this->renewToken(command); + _mutex_unlock(&m_parallelTokRenewMutex); + } + else + { + break; + } + } while (true); + + continue; + } + tp.AddJob([metadata, resultIndex, command, this]()->void { do { diff --git a/include/snowflake/version.h b/include/snowflake/version.h index 1ead06921a..192dc3360f 100644 --- a/include/snowflake/version.h +++ b/include/snowflake/version.h @@ -5,6 +5,6 @@ #ifndef SNOWFLAKE_CLIENT_VERSION_H #define SNOWFLAKE_CLIENT_VERSION_H -#define SF_API_VERSION "0.5.1" +#define SF_API_VERSION "0.5.3" #endif /* SNOWFLAKE_CLIENT_VERSION_H */