Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-3557

C function next_object_id erroring when creating a new document on a has_many collection

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: bson-5.0.1
    • Component/s: BSON
    • None
    • Ruby Drivers

      BSON Gem version: 5.0.1

      MongoDB Server: Production 6.0/8.0, Development: 3.6
      Architecture: arm64, x86 64
       
      The issue occurs when trying to create a new object on a has many collection inside a Sidekiq job. The issue effects both development and production environments.
       
      Below are some excerpts from server logs, one in development, one in production. 
       
      This log excerpt is from a development environment

      09:01:40 sidekiq.1 | 2024-10-24T09:01:40.927Z pid=6097 tid=dal class=PublishEvent jid=d0c3610d70eb3ecc7dea8f67 uniquejobs=server until_executed=uniquejobs:6ccbe9b38a21eca38d4e8a9bc8e90220 WARN: Overwriting existing field type in class Workflow.09:01:41 sidekiq.1 | /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/bson-5.0.1/lib/bson/object_id.rb:246: [BUG] Segmentation fault at 0x0000ffffa060f84009:01:41 sidekiq.1 | ruby 3.3.1 (2024-04-23 revision c56cd86388) +YJIT [aarch64-linux]09:01:41 sidekiq.1 | 09:01:41 sidekiq.1 | -- Control frame information -----------------------------------------------09:01:41 sidekiq.1 | c:0106 p:---- s:0575 e:000574 CFUNC  :next_object_id09:01:41 sidekiq.1 | c:0105 p:0022 s:0571 e:000570 METHOD /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/bson-5.0.1/lib/bson/object_id.rb:24609:01:41 sidekiq.1 | c:0104 p:0003 s:0567 e:000566 METHOD /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/bson-5.0.1/lib/bson/object_id.rb:123 [FINISH]09:01:41 sidekiq.1 | c:0103 p:0011 s:0563 e:000559 METHOD /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/mongoid-8.1.6/lib/mongoid/association/referenced/has_many/enumerable.rb:6409:01:41 sidekiq.1 | c:0102 p:0007 s:0555 e:000554 BLOCK  /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/mongoid-8.1.6/lib/mongoid/association/referenced/has_many/proxy.rb:33409:01:41 sidekiq.1 | c:0101 p:0014 s:0552 e:000551 METHOD /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/mongoid-8.1.6/lib/mongoid/association/referenced/has_many/proxy.rb:35109:01:41 sidekiq.1 | c:0100 p:0011 s:0546 e:000545 METHOD /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/mongoid-8.1.6/lib/mongoid/association/referenced/has_many/proxy.rb:33309:01:41 sidekiq.1 | c:0099 p:0031 s:0541 e:000540 METHOD /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/mongoid-8.1.6/lib/mongoid/association/referenced/has_many/proxy.rb:7509:01:41 sidekiq.1 | c:0098 p:0031 s:0534 e:000533 METHOD /workspaces/v1_reflow/vendor/bundle/ruby/3.3.0/gems/mongoid-8.1.6/lib/mongoid/association/many.rb:3909:01:41 sidekiq.1 | c:0097 p:0017 s:0526 E:000e58 METHOD /workspaces/byte/app/services/event_logger.rb:27(Tries to create a new document on a has_many collection) 

      This additional log excerpt is from the same error but in a production environment

      ERROR 2024-10-23T15:38:54.528391199Z -- C level backtrace information -------------------------------------------ERROR 2024-10-23T15:38:54.790156149Z /usr/local/lib/libruby.so.3.3(rb_print_backtrace+0x14) [0x7da185096aeb] /usr/src/ruby/vm_dump.c:820ERROR 2024-10-23T15:38:54.790210580Z /usr/local/lib/libruby.so.3.3(rb_vm_bugreport) /usr/src/ruby/vm_dump.c:1151ERROR 2024-10-23T15:38:54.790217940Z /usr/local/lib/libruby.so.3.3(rb_bug_for_fatal_signal+0x100) [0x7da184e8fc10] /usr/src/ruby/error.c:1065ERROR 2024-10-23T15:38:54.790225030Z /usr/local/lib/libruby.so.3.3(sigsegv+0x4b) [0x7da184fe24fb] /usr/src/ruby/signal.c:926ERROR 2024-10-23T15:38:54.790231260Z /lib/x86_64-linux-gnu/libc.so.6(0x7da184a13050) [0x7da184a13050]ERROR 2024-10-23T15:38:54.790236710Z /usr/local/lib/libruby.so.3.3(RBASIC_CLASS+0x0) [0x7da18508a760] ./include/ruby/internal/globals.h:178ERROR 2024-10-23T15:38:54.790242980Z /usr/local/lib/libruby.so.3.3(gccct_method_search) /usr/src/ruby/vm_eval.c:475ERROR 2024-10-23T15:38:54.790248580Z /usr/local/lib/libruby.so.3.3(rb_funcallv_scope) /usr/src/ruby/vm_eval.c:1063ERROR 2024-10-23T15:38:54.790253660Z /usr/local/lib/libruby.so.3.3(rb_funcallv) /usr/src/ruby/vm_eval.c:1084ERROR 2024-10-23T15:38:54.790260530Z /usr/local/bundle/ruby/3.3.0/gems/bson-5.0.1/lib/bson_native.so(pvt_rand_buf+0x75) [0x7da15fd37665] /usr/local/bundle/ruby/3.3.0/gems/bson-5.0.1/ext/bson/util.c:205ERROR 2024-10-23T15:38:54.790265950Z /usr/local/bundle/ruby/3.3.0/gems/bson-5.0.1/lib/bson_native.so(pvt_rand_buf) (null):0ERROR 2024-10-23T15:38:54.790272290Z /usr/local/bundle/ruby/3.3.0/gems/bson-5.0.1/lib/bson_native.so(pvt_get_object_id_random_value+0x2a) [0x7da15fd3775a] /usr/local/bundle/ruby/3.3.0/gems/bson-5.0.1/ext/bson/util.c:159ERROR 2024-10-23T15:38:54.790277500Z /usr/local/bundle/ruby/3.3.0/gems/bson-5.0.1/lib/bson_native.so(rb_bson_object_id_generator_next+0x69) [0x7da15fd377c9] /usr/local/bundle/ruby/3.3.0/gems/bson-5.0.1/ext/bson/util.c:77ERROR 2024-10-23T15:38:54.790283060Z [0x7da185ddc8fa]ERROR 2024-10-23T15:38:54.790288840Z {}
       

       
      Thanks, and please do let us know if more information is required.

            Assignee:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Reporter:
            ben@superbyte.uk Ben Weatherley
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: