mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-01 21:55:50 +00:00
The user types storage is needed in cql_type_parser::parse which is in turn called with either replica::database or scema_ctxt at hand. To facilitate the former case replica::database has its own user types storage created in database constructor. The latter case is a bit trickier. In many cases the ctxt is created as a temporary object and the database is available at those places. Also the ctxt object lives on the schema_registry instance which doesn't have database nearby. However, that ctxt lifetime is the same as the registry instance one and when it's created there's a database at hand (it's the database constructor that calls schema_registry.init() passing "this" into it). Thus, the solution is to make database's user types storage be a shared pointer that's shared between database itself and all the ctxts out there including the one that lives on schema_registry instance. When database goes away it .deactivate()s its user types storage so that any ctxts that may share it stay on the safe side and don't use database after free. This part will go away when the schema_registry will be deglobalized. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>