grosser / parallel

Ruby: parallel processing made simple and fast
MIT License
4.16k stars 254 forks source link

Segmentation fault #337

Open mario-amazing opened 1 year ago

mario-amazing commented 1 year ago

I have Segmentation fault error in the sidekiq container:

    rails (7.0.6)
    parallel (1.23.0)
    sidekiq (7.1.2)

Docker image: FROM ruby:3.2.2-alpine

Any ideas how to fix it?

/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:568: [BUG] Segmentation fault at 0x0000000000000000
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [x86_64-linux-musl]

-- Control frame information -----------------------------------------------
c:0078 p:---- s:0432 e:000431 CFUNC  :fork
c:0077 p:0027 s:0428 e:000427 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:568
c:0076 p:0019 s:0416 e:000414 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:559 [FINISH]
c:0075 p:---- s:0410 e:000409 IFUNC
c:0074 p:---- s:0407 e:000406 CFUNC  :each
c:0073 p:---- s:0404 e:000403 CFUNC  :each_with_index
c:0072 p:0017 s:0400 e:000399 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:558
c:0071 p:0011 s:0392 e:000391 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:497
c:0070 p:0317 s:0381 e:000380 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:291
c:0069 p:0019 s:0370 e:000369 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:235
c:0068 p:0017 s:0363 e:000362 METHOD /app/app/services/xlsx/free_slots/upserter.rb:9
c:0067 p:0013 s:0359 e:000358 METHOD /app/app/services/application_service.rb:2
c:0066 p:0004 s:0352 e:000351 METHOD /app/app/sidekiq/xlsx_free_slots_upserter_job.rb:7
c:0065 p:0008 s:0348 e:000347 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:209
c:0064 p:0012 s:0342 e:000341 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:177
c:0063 p:0012 s:0339 e:000338 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:180
c:0062 p:0016 s:0331 e:000330 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:183
c:0061 p:0003 s:0328 e:000327 BLOCK  /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/lock/until_executed.rb:37
c:0060 p:0012 s:0325 e:000324 METHOD /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/locksmith.rb:193
c:0059 p:0014 s:0318 e:000317 BLOCK  /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/locksmith.rb:106
c:0058 p:0009 s:0314 e:000313 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/redis-client-0.14.1/lib/redis_client/decorator.rb:46
c:0057 p:0006 s:0310 e:000309 METHOD /app/vendor/bundle/ruby/3.2.0/gems/redis-client-0.14.1/lib/redis_client.rb:182
c:0056 p:0010 s:0305 e:000304 METHOD /app/vendor/bundle/ruby/3.2.0/gems/redis-client-0.14.1/lib/redis_client/decorator.rb:46
c:0055 p:0008 s:0300 e:000299 BLOCK  /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/connection.rb:16
c:0054 p:0009 s:0296 e:000295 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/capsule.rb:102
c:0053 p:0004 s:0290 e:000289 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:110 [FINISH]
c:0052 p:---- s:0287 e:000286 CFUNC  :handle_interrupt
c:0051 p:0019 s:0282 e:000281 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109 [FINISH]
c:0050 p:---- s:0278 e:000277 CFUNC  :handle_interrupt
c:0049 p:0015 s:0273 e:000272 METHOD /app/vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106
c:0048 p:0019 s:0268 e:000267 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/capsule.rb:99
c:0047 p:0021 s:0264 e:000263 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq.rb:73
c:0046 p:0008 s:0259 e:000258 METHOD /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/connection.rb:15
c:0045 p:0020 s:0253 e:000252 METHOD /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/locksmith.rb:105
c:0044 p:0006 s:0248 e:000247 METHOD /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/lock/until_executed.rb:36
c:0043 p:0009 s:0243 e:000242 METHOD /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/middleware/server.rb:27
c:0042 p:0012 s:0237 e:000236 BLOCK  /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/middleware.rb:41
c:0041 p:0002 s:0234 e:000233 BLOCK  /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/logging.rb:142
c:0040 p:0017 s:0231 e:000230 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/logger.rb:11 [FINISH]
c:0039 p:---- s:0225 e:000224 CFUNC  :call
c:0038 p:0012 s:0220 e:000219 METHOD /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/logging.rb:157
c:0037 p:0004 s:0215 E:001690 METHOD /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/logging.rb:141
c:0036 p:0051 s:0211 E:0003d0 METHOD /app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/middleware.rb:40
c:0035 p:0026 s:0203 E:001280 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:182
c:0034 p:0016 s:0195 e:000194 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:183
c:0033 p:0121 s:0192 e:000191 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sentry-sidekiq-5.9.0/lib/sentry/sidekiq/sentry_context_middleware.rb:26
c:0032 p:0026 s:0181 e:000180 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:182
c:0031 p:0016 s:0173 e:000172 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:183
c:0030 p:0015 s:0170 e:000169 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/metrics/tracking.rb:26
c:0029 p:0027 s:0161 e:000160 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/metrics/tracking.rb:122
c:0028 p:0026 s:0153 e:000152 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:182
c:0027 p:0025 s:0145 e:000144 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:173
c:0026 p:0014 s:0138 E:0014e8 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:176
c:0025 p:0004 s:0134 e:000133 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:140
c:0024 p:0002 s:0131 e:000130 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/job_retry.rb:114
c:0023 p:0045 s:0120 e:000119 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:139
c:0022 p:0002 s:0115 e:000114 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/rails.rb:16
c:0021 p:0015 s:0112 e:000111 METHOD /app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/execution_wrapper.rb:92
c:0020 p:0004 s:0106 e:000105 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/reloader.rb:72
c:0019 p:0015 s:0103 e:000102 METHOD /app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/execution_wrapper.rb:92
c:0018 p:0006 s:0097 e:000096 METHOD /app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/reloader.rb:71
c:0017 p:0026 s:0093 e:000092 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/rails.rb:15
c:0016 p:0006 s:0088 e:000087 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:135
c:0015 p:0028 s:0085 e:000084 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:270
c:0014 p:0010 s:0079 e:000078 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:130
c:0013 p:0018 s:0076 e:000075 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/job_logger.rb:13
c:0012 p:0012 s:0069 e:000068 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:129
c:0011 p:0002 s:0066 e:000065 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/job_retry.rb:81
c:0010 p:0010 s:0056 e:000055 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:128
c:0009 p:0129 s:0053 e:000052 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/job_logger.rb:39
c:0008 p:0008 s:0045 e:000044 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:127
c:0007 p:0040 s:0038 E:002068 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:175
c:0006 p:0017 s:0025 e:000024 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:82
c:0005 p:0021 s:0020 e:000019 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:72 [FINISH]
c:0004 p:---- s:0015 e:000014 IFUNC
c:0003 p:0002 s:0012 e:000011 METHOD /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/component.rb:10
c:0002 p:0026 s:0006 e:000005 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/component.rb:19 [FINISH]
c:0001 p:---- s:0003 e:000002 DUMMY  [FINISH]

-- Ruby level backtrace information ----------------------------------------
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/component.rb:19:in `block in safe_thread'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/component.rb:10:in `watchdog'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:72:in `run'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:82:in `process_one'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:175:in `process'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:127:in `dispatch'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/job_logger.rb:39:in `prepare'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:128:in `block in dispatch'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/job_retry.rb:81:in `global'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:129:in `block (2 levels) in dispatch'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/job_logger.rb:13:in `call'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:130:in `block (3 levels) in dispatch'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:270:in `stats'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:135:in `block (4 levels) in dispatch'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/rails.rb:15:in `call'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/reloader.rb:71:in `wrap'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/execution_wrapper.rb:92:in `wrap'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/reloader.rb:72:in `block in wrap'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/execution_wrapper.rb:92:in `wrap'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/rails.rb:16:in `block in call'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:139:in `block (5 levels) in dispatch'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/job_retry.rb:114:in `local'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:140:in `block (6 levels) in dispatch'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:176:in `block in process'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:173:in `invoke'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:182:in `traverse'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/metrics/tracking.rb:122:in `call'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/metrics/tracking.rb:26:in `track'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:182:in `traverse'
/app/vendor/bundle/ruby/3.2.0/gems/sentry-sidekiq-5.9.0/lib/sentry/sidekiq/sentry_context_middleware.rb:26:in `call'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:182:in `traverse'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/middleware.rb:40:in `call'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/logging.rb:141:in `with_logging_context'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/logging.rb:157:in `with_configured_loggers_context'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/logging.rb:157:in `call'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/logger.rb:11:in `with'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/logging.rb:142:in `block in with_logging_context'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/middleware.rb:41:in `block in call'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/middleware/server.rb:27:in `call'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/lock/until_executed.rb:36:in `execute'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/locksmith.rb:105:in `execute'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/connection.rb:15:in `redis'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq.rb:73:in `redis'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/capsule.rb:99:in `redis'
/app/vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `with'
/app/vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:106:in `handle_interrupt'
/app/vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `block in with'
/app/vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:109:in `handle_interrupt'
/app/vendor/bundle/ruby/3.2.0/gems/connection_pool-2.4.1/lib/connection_pool.rb:110:in `block (2 levels) in with'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/capsule.rb:102:in `block in redis'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/connection.rb:16:in `block in redis'
/app/vendor/bundle/ruby/3.2.0/gems/redis-client-0.14.1/lib/redis_client/decorator.rb:46:in `with'
/app/vendor/bundle/ruby/3.2.0/gems/redis-client-0.14.1/lib/redis_client.rb:182:in `with'
/app/vendor/bundle/ruby/3.2.0/gems/redis-client-0.14.1/lib/redis_client/decorator.rb:46:in `block in with'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/locksmith.rb:106:in `block in execute'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/locksmith.rb:193:in `lock!'
/app/vendor/bundle/ruby/3.2.0/bundler/gems/sidekiq-unique-jobs-b31e80bc5542/lib/sidekiq_unique_jobs/lock/until_executed.rb:37:in `block in execute'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/middleware/chain.rb:180:in `traverse'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:177:in `block (2 levels) in process'
/app/vendor/bundle/ruby/3.2.0/gems/sidekiq-7.1.2/lib/sidekiq/processor.rb:209:in `execute_job'
/app/app/sidekiq/xlsx_free_slots_upserter_job.rb:7:in `perform'
/app/app/services/application_service.rb:2:in `call'
/app/app/services/xlsx/free_slots/upserter.rb:9:in `call'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:235:in `each'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:291:in `map'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:497:in `work_in_processes'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:558:in `create_workers'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:558:in `each_with_index'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:558:in `each'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:559:in `block in create_workers'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:568:in `worker'
/app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:568:in `fork'

-- Machine register context ------------------------------------------------
 RIP: 0x00007f3e26a7f69f RBP: 0x00007f3e26a57b40 RSP: 0x00007f3e1138cc18
 RAX: 0x02b000007f3e1dfc RBX: 0x00007f3e11ed38d0 RCX: 0x0000000000000000
 RDX: 0x0000000000000001 RDI: 0x00007f3e0f39be00 RSI: 0x0000000000000000
  R8: 0x00007f3e0f39be20  R9: 0x0000000000000000 R10: 0x0000000000000000
 R11: 0x0000000000000246 R12: 0x00007f3e1138cca0 R13: 0x00007f3e120130a0
 R14: 0x00007f3e26371040 R15: 0x00007f3e11d84928 EFL: 0x0000000000010206

-- Other runtime information -----------------------------------------------

* Loaded script: sidekiq 7.1.2 app [0 of 10 busy]
grosser commented 1 year ago

I'd say try running without yjit and see if that is better. Otherwise reproduce in a minimal example to see if it's really parallel causing that or just fork.

mario-amazing commented 1 year ago

@grosser, without yjit I have the same error.

 /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:568: [BUG] Segmentation fault at 0x0000000000000010
 ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux-musl]

 -- Control frame information -----------------------------------------------
 c:0078 p:---- s:0432 e:000431 CFUNC  :fork
 c:0077 p:0027 s:0428 e:000427 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:568
 c:0076 p:0019 s:0416 e:000414 BLOCK  /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:559 [FINISH]
 c:0075 p:---- s:0410 e:000409 IFUNC
 c:0074 p:---- s:0407 e:000406 CFUNC  :each
 c:0073 p:---- s:0404 e:000403 CFUNC  :each_with_index
 c:0072 p:0017 s:0400 e:000399 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:558
 c:0071 p:0011 s:0392 e:000391 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:497
 c:0070 p:0317 s:0381 e:000380 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:291
 c:0069 p:0019 s:0370 e:000369 METHOD /app/vendor/bundle/ruby/3.2.0/gems/parallel-1.23.0/lib/parallel.rb:235
mario-amazing commented 1 year ago

With threads everything is fine { in_threads: Etc.nprocessors }

grosser commented 1 year ago

try running the same code with just fork to see if this is a ruby bug or a parallel bug

grosser commented 1 year ago

and try to build a minimal example so it's easy to reproduce/debug

mario-amazing commented 1 year ago

I've tried parallels in_processes and fork in console. Everything is fine. But this issue is rare on the production server and I don't know how to catch it. => Only errors in the log file

grosser commented 1 year ago

it looks like the is running in sidekiq which means it's also running in parallel threads already right ? maybe a solution is to use Thread.exclusive to eliminate that ? ... other idea would be to "dumb down" whatever it does inside, so instead of writing to disk/db just return a string and then write that in serial after the block, basically reduce the block to the essential slow part and do the rest outside

mario-amazing commented 1 year ago

This is a separate sidekiq docker container. Inside of parallel execution: external API request and handling data from it

grosser commented 1 year ago

maybe the api requests could be done in parallel threads and then data processing in forks

tisba commented 11 months ago

it looks like the is running in sidekiq which means it's also running in parallel threads already right ?

I'm also seeing this from time to time, but wasn't successful yet to cleanly reproduce this.

maybe a solution is to use Thread.exclusive to eliminate that ?

I think Thread.exclusive has been deprecated a long time ago and was removed some time ago (at least in recent Rubys it is no longer available). Where would you apply a mutex exactly?

In our case, we are using processes, as the task we're doing is pretty CPU intensive and benefits greatly from true parallelism. I suspect that some combination of Sidekiq's threads + forking from parallel triggers an issue in some cases, especially if there are multiple sidekiq threads doing Parallel.map(in_processes: …). This also seems to cause parallel's processes to hang sometimes, but again, wasn't able to reproduce this outside of production and troubleshooting this is pretty messy currently 😢