diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-11 00:00:49 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-11 00:10:21 +0300 |
commit | d9ca3d91a6a120bab62af1f5abe12097ed705c59 (patch) | |
tree | 4ca19219a67396acb1ff5df906a934f1f83a0366 | |
parent | 039092e9758c77a5f868f68056d7ba02ef7dffa7 (diff) | |
download | ydb-d9ca3d91a6a120bab62af1f5abe12097ed705c59.tar.gz |
Intermediate changes
-rw-r--r-- | yt/yt/library/process/process.cpp | 27 | ||||
-rw-r--r-- | yt/yt/library/process/process.h | 2 |
2 files changed, 9 insertions, 20 deletions
diff --git a/yt/yt/library/process/process.cpp b/yt/yt/library/process/process.cpp index 3f9b2cab92..5dbd21d5be 100644 --- a/yt/yt/library/process/process.cpp +++ b/yt/yt/library/process/process.cpp @@ -62,13 +62,6 @@ YT_DEFINE_GLOBAL(const NLogging::TLogger, Logger, "Process"); static constexpr pid_t InvalidProcessId = -1; -#if !defined(YT_USE_POSIX_SPAWN_API) - -static constexpr int ExecveRetryCount = 5; -static constexpr auto ExecveRetryTimeout = TDuration::Seconds(1); - -#endif - static constexpr int ResolveRetryCount = 5; static constexpr auto ResolveRetryTimeout = TDuration::Seconds(1); @@ -559,17 +552,10 @@ public: #else SpawnActions_.push_back(TSpawnAction{ [=] { - for (int retryIndex = 0; retryIndex < ExecveRetryCount; ++retryIndex) { - // Execve may fail, if called binary is being updated, e.g. during yandex-yt package update. - // So we'd better retry several times. - // For example see YT-6352. - TryExecve(resolvedPath, argv, env); - if (retryIndex < ExecveRetryCount - 1) { - Sleep(ExecveRetryTimeout); - } - } - // If we are still here, return failure. - return false; + // Execve may fail, if called binary is being updated, e.g. during yandex-yt package update + // with errno ETXTBSY - executable file is open for writing. For example see YT-6352. + // Initiator could retry after getting error EProcessErrorCode::CannotStartProcess. + return TryExecve(resolvedPath, argv, env); }, "Error starting child process: execve failed" }); @@ -629,8 +615,9 @@ private: #else pid_t DoSpawnChildVFork() { - // NB: fork() will cause data corruption when run concurrently with - // Disk IO on O_DIRECT file descriptor. Seems like vfork don't suffer from the same issue. + // NB: fork() copy-on-write cause undefined behaviour when run concurrently with + // Disk IO on O_DIRECT file descriptor. vfork don't suffer from the same issue. + // NB: vfork() blocks parent until child executes new program or exits. int pid = vfork(); if (pid < 0) { diff --git a/yt/yt/library/process/process.h b/yt/yt/library/process/process.h index 6e56e0ea10..e642515092 100644 --- a/yt/yt/library/process/process.h +++ b/yt/yt/library/process/process.h @@ -41,7 +41,9 @@ public: virtual NNet::IConnectionReaderPtr GetStdOutReader() = 0; virtual NNet::IConnectionReaderPtr GetStdErrReader() = 0; + //! Returns process completion future, which ends with EErrorCode::OK or EProcessErrorCode. TFuture<void> Spawn(); + virtual void Kill(int signal) = 0; TString GetPath() const; |