Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid lock when ecs_compatibility is explicitly specified (#16786)
Because a `break` escapes a `begin`...`end` block, we must not use a `break` in order to ensure that the explicitly set value gets memoized to avoid lock contention. > ~~~ ruby > def fake_sync(&block) > puts "FAKE_SYNC:enter" > val = yield > puts "FAKE_SYNC:return(#{val})" > return val > ensure > puts "FAKE_SYNC:ensure" > end > > fake_sync do > @ivar = begin > puts("BE:begin") > break :break > > val = :ret > puts("BE:return(#{val})") > val > ensure > puts("BE:ensure") > end > end > ~~~ Note: no `FAKE_SYNC:return`: > ~~~ > ╭─{ rye@perhaps:~/src/elastic/logstash (main ✔) } > ╰─● ruby break-esc.rb > FAKE_SYNC:enter > BE:begin > BE:ensure > FAKE_SYNC:ensure > [success] > ~~~ (cherry picked from commit 01c8e8b)
- Loading branch information