4 ms·
Isn't the real risk running different versions simultaneously (both of Ruby and the libraries) in production and having them sharing state via a serialisation f
by josephlord 12y ago
Isn't the real risk running different versions simultaneously (both of Ruby and the libraries) in production and having them sharing state via a serialisation format.
- cpayne624 12y agoI would say so
- jrochkind1 12y agoExcept if that serialization format was Json, we'd both be shocked if there were any problems, wouldn't we? It's possible, but pretty darn unlikely. And if that serialization format were ruby marshal... there's actually a 'marshal version' embedded with marshaled serializations, which changes independently of ruby version, can change to indicate backwards incompat, but I don't believe has changed in quite some time, not between 1.9.3 and 2.1.x. So again, if the marshal version is the same, we'd be shocked (and it would unambiguously be a bug) if there were anything handled differently between versions. (Okay, that's not entirely true, I can think of some counter-examples too). I think it really is about YAML, and the mistaken design decisions in the way much of rubydom has historically used it, which continue to pile up. Note that I think ActiveRecord `serialized` uses YAML in the db, so that's another place you might find yourself "sharing state" via YAML between diff ruby versions -- if you upgrade to ruby 2.1 and have it reading a database created with an earlier ruby version. Oops. Maybe the lesson is really that serialization is way harder to get right than you think, in terms of both security and forwards compatibility (future-proofness).
- josephlord 12y agoBy serialisation I meant something that dumps objects like Python's pickle. Maybe marshal is a better equivalent. If there was version checking as you say there is in marshal it would still have failed in production but the errors would be better. Are you sure Activerecord uses YAML in the DB? Everything I've used it for is stored as the native database types. What is the need to serialize the object into the DB rather than create a new one based on the record in the DB? Nowhere did I say serialisation was easy. My comment was that running multiple versions of platform and libraries at once sharing state was brave. To do that I would want to be completely explicit about the state format and have tests to ensure it is correct even though it is an internal API. Better not to share anything between the servers and just have them all accessing the same service that owns the state format (probably the DB but possibly also caching layers[risky needs managing] and other services).
- byroot 12y ago> Are you sure Activerecord uses YAML in the DB ActiveRecord use YAML (by default) to serialize non scalar values like hashes and arrays.
- josephlord 12y agoOK, I don't actually use them, my data model is pretty pure relational (edit: and normalised) although I might start using the Postgres array and hstore/json column types at some point I guess that boundary would prevent serialization issues troubling me.
- jrochkind1 12y agoActiveRecord uses YAML if you tell it to serialize an object to a text column with the AR `serialize` feature. http://apidock.com/rails/ActiveRecord/AttributeMethods/Serialization/ClassMethods/serialize http://apidock.com/rails/ActiveRecord/AttributeMethods/Seria...