Skip to content

Commit a68aba4

Browse files
committed
Fix deadlock in case test performs lots of checks without yielding
Before commit 6c5c8b7 ("Print luatest logs to stdout when unified log is disabled"), luatest implicitly configured the logger to operate in the non-blocking mode by using a pipe for the logs destination. Now, it uses a file albeit the file actually points to a pipe file descriptor. Tarantool thinks it's a regular file and writes all logs in the blocking mode. This leads to a deadlock if a test performs a lot of checks (which are logged) without yielding execution to the fiber processing logs because the size of a pipe is quite limited. Let's fix this issue by writing all logs through a pipe, as we did before. Let's also explicitly enable non-blocking logging to avoid breakages like this in future. The fix isn't ideal because it may lead to dropping logs. We should probably handle logs emitted by the luatest runner in a separate process, like we do for processes spawned in tests. Closes #416
1 parent 6c5c8b7 commit a68aba4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

luatest/log.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ function log.initialize(options)
4242
output_beautifier:enable()
4343

4444
-- Redirect all logs to the pipe created by OutputBeautifier.
45-
local log_cfg = string.format('/dev/fd/%d', output_beautifier.pipes.stdout[1])
45+
--
46+
-- Write through a pipe to enable non-blocking mode. Required to prevent
47+
-- a deadlock in case a test performs a lot of checks without yielding
48+
-- execution to the fiber processing logs (gh-416).
49+
local log_cfg = string.format('| cat > /dev/fd/%d',
50+
output_beautifier.pipes.stdout[1])
4651

4752
-- Logging cannot be initialized without configuring the `box` engine
4853
-- on a version less than 2.5.1 (see more details at [1]). Otherwise,
@@ -59,7 +64,10 @@ function log.initialize(options)
5964
-- Initialize logging for luatest runner.
6065
-- The log format will be as follows:
6166
-- YYYY-MM-DD HH:MM:SS.ZZZ [ID] main/.../luatest I> ...
62-
require('log').cfg{log = log_cfg}
67+
require('log').cfg{
68+
log = log_cfg,
69+
nonblock = true,
70+
}
6371
end
6472

6573
is_initialized = true

0 commit comments

Comments
 (0)