pietermartin / sqlg

TinkerPop graph over sql
MIT License
245 stars 51 forks source link

Add option to prevent on-demand schema creation #334

Closed ktschmidt closed 2 years ago

ktschmidt commented 5 years ago

Sqlg normally creates/modifies the schema in the back-end database on demand, e.g. the first time a vertex or edge is created or as properties are created on them the first time. This is convenient in many environments, but a production system likely wants to lock down the schema and not allow adhoc/rogue schema changes and/or doesn't want to risk the deadlocks that can occur when introducing DDL in the middle of a busy system doing a lot of DDL.

One way to address this would be to have a mode that can be enabled through configuration where adhoc/on-demand schema creation is not allowed and schema creation must be done using the Topology class(es).

Note that this approach would work well for our use case where we have a model definition in a JSON file that we read in and use the Topology classes to create the schema. Any schema changes would first have us update our model definition and then use the Topology classes to effect the change.

pietermartin commented 2 years ago

Implemented this one incorrectly, needs some more thinking about transaction scopes and multiple threads

pietermartin commented 2 years ago

Added a transaction scoped unlockTopology. This leaves the global lock locked and only allows the current thread to make changes.