Skip to content

Commit

Permalink
SNOW 162610: Do not use thread pool when parallel=1 (#213)
Browse files Browse the repository at this point in the history
* Do not use thread pool when parallel=1

* Version bump to test with ODBC driver

Co-authored-by: Harry Xi <[email protected]>
  • Loading branch information
sfc-gh-vreddy and Harry Xi authored Jun 29, 2020
1 parent d8dc254 commit d1af142
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions cpp/FileTransferAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion include/snowflake/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit d1af142

Please sign in to comment.