MCPcopy Create free account
hub / github.com/apache/cloudberry / UploadThreadFunc

Method UploadThreadFunc

gpcontrib/gpcloud/src/s3key_writer.cpp:85–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83};
84
85void* S3KeyWriter::UploadThreadFunc(void* data) {
86 MaskThreadSignals();
87
88 ThreadParams* params = (ThreadParams*)data;
89 S3KeyWriter* writer = params->keyWriter;
90
91 try {
92 S3DEBUG("Upload thread start: %" PRIX64 ", part number: %" PRIu64 ", data size: %zu",
93 (uint64_t) pthread_self(), params->currentNumber, params->data.size());
94 string etag = writer->s3Interface->uploadPartOfData(
95 params->data, writer->params.getS3Url(), params->currentNumber, writer->uploadId);
96
97 // when unique_lock destructs it will automatically unlock the mutex.
98 UniqueLock threadLock(&writer->mutex);
99
100 // etag is empty if the query is cancelled by user.
101 if (!etag.empty()) {
102 writer->etagList[params->currentNumber] = etag;
103 }
104 writer->activeThreads--;
105 pthread_cond_broadcast(&writer->cv);
106 S3DEBUG("Upload part finish: %" PRIX64 ", eTag: %s, part number: %" PRIu64, (uint64_t) pthread_self(),
107 etag.c_str(), params->currentNumber);
108 } catch (S3Exception& e) {
109 S3ERROR("Upload thread error: %s", e.getMessage().c_str());
110 UniqueLock exceptLock(&writer->exceptionMutex);
111 writer->sharedError = true;
112 writer->sharedException = std::current_exception();
113
114 // notify the flushBuffer, otherwise it will be locked when trying to create a new thread.
115 writer->activeThreads--;
116 pthread_cond_broadcast(&writer->cv);
117 }
118
119 delete params;
120 return NULL;
121}
122
123void S3KeyWriter::flushBuffer() {
124 if (!this->buffer.empty()) {

Callers

nothing calls this directly

Calls 5

pthread_selfFunction · 0.85
uploadPartOfDataMethod · 0.80
MaskThreadSignalsFunction · 0.70
sizeMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected