Skip to content
  • Sam Bostock's avatar
    bc1f3233
    Add ActiveJob::Serializers::BigDecimalSerializer · bc1f3233
    Sam Bostock authored
    Previously, BigDecimal was listed as not needing a serializer.  However,
    when used with an adapter storing the job arguments as JSON, it would get
    serialized as a simple String, resulting in deserialization also producing
    a String (instead of a BigDecimal).
    
    By using a serializer, we ensure the round trip is safe.
    
    During upgrade deployments of applications with multiple replicas making use of
    BigDecimal job arguments with a queue adapter serializing to JSON, there exists
    a possible race condition, whereby a "new" replica enqueues a job with an
    argument serialized using `BigDecimalSerializer`, and an "old" replica fails to
    deserialize it (as it does not have `BigDecimalSerializer`).
    
    Therefore, to ensure safe upgrades, serialization will not use
    `BigDecimalSerializer` until `config.active_job.use_big_decimal_serializer` is
    enabled, which can be done safely after successful deployment of Rails 7.1.
    
    This option will be removed in Rails 7.2, when it will become the default.
    bc1f3233
    Add ActiveJob::Serializers::BigDecimalSerializer
    Sam Bostock authored
    Previously, BigDecimal was listed as not needing a serializer.  However,
    when used with an adapter storing the job arguments as JSON, it would get
    serialized as a simple String, resulting in deserialization also producing
    a String (instead of a BigDecimal).
    
    By using a serializer, we ensure the round trip is safe.
    
    During upgrade deployments of applications with multiple replicas making use of
    BigDecimal job arguments with a queue adapter serializing to JSON, there exists
    a possible race condition, whereby a "new" replica enqueues a job with an
    argument serialized using `BigDecimalSerializer`, and an "old" replica fails to
    deserialize it (as it does not have `BigDecimalSerializer`).
    
    Therefore, to ensure safe upgrades, serialization will not use
    `BigDecimalSerializer` until `config.active_job.use_big_decimal_serializer` is
    enabled, which can be done safely after successful deployment of Rails 7.1.
    
    This option will be removed in Rails 7.2, when it will become the default.
Loading