Open wvandeun opened 1 day ago
The problem is with this index:
SHOW INDEXES where name = "node_range_attr_value_value";
╒═══╤═════════════════════════════╤════════╤═════════════════╤═══════╤══════════╤══════════════════╤══════════╤═════════════╤════════════════╤════════╤═════════╕
│id │name │state │populationPercent│type │entityType│labelsOrTypes │properties│indexProvider│owningConstraint│lastRead│readCount│
╞═══╪═════════════════════════════╪════════╪═════════════════╪═══════╪══════════╪══════════════════╪══════════╪═════════════╪════════════════╪════════╪═════════╡
│7 │"node_range_attr_value_value"│"ONLINE"│100.0 │"RANGE"│"NODE" │["AttributeValue"]│["value"] │"range-1.0" │null │null │0 │
└───┴─────────────────────────────┴────────┴─────────────────┴───────┴──────────┴──────────────────┴──────────┴─────────────┴────────────────┴────────┴─────────┘
This doc is for an earlier version of neo4j, but seems relevant: https://neo4j.com/developer/kb/index-limitations-and-workaround/
The native-btree-1.0 index provider has a key size limit of 8167 bytes.
While we're not using the same exact index provider it seems to have the same size limit.
A quick workaround can be to remove the index from the database, but there will probably be some performance penalty to this.
DROP index node_range_attr_value_value;
The problem is not related to the GraphQL query objects themselves, instead it's the value of any field.
If we look at the definition of these objects as defined below a solution might be to set a size limit for the kinds Text
and others, and then use something other than the AttributeValue
label for other field types such as TextArea
and JSON
such as LargeAttributeValue
where the large one is unindexed. Though I don't yet know the impact this will have on the query engine.
Alternatively we reconsider the use of this index all together.
{
"name": "GraphQLQuery",
"namespace": "Core",
"description": "A pre-defined GraphQL Query",
"include_in_menu": False,
"icon": "mdi:graphql",
"label": "GraphQL Query",
"default_filter": "name__value",
"order_by": ["name__value"],
"display_labels": ["name__value"],
"generate_profile": False,
"branch": BranchSupportType.AWARE.value,
"uniqueness_constraints": [["name__value"]],
"documentation": "/topics/graphql",
"attributes": [
{"name": "name", "kind": "Text", "unique": True},
{"name": "description", "kind": "Text", "optional": True},
{"name": "query", "kind": "TextArea"},
{
"name": "variables",
"kind": "JSON",
"description": "variables in use in the query",
"optional": True,
"read_only": True,
},
Great summary @ogenstad
I'm leaning toward this solution
use something other than the AttributeValue label for other field types such as TextArea and JSON such as LargeAttributeValue where the large one is unindexed.
Component
API Server / GraphQL
Infrahub version
0.16.0
Current Behavior
When you try to store a large GraphQL query in Infrahub (query used for a transformation synced into Infrahub, or a user create CoreGraphQLQuery object) you get a neo4j.exceptions.DatabaseError exception.
Expected Behavior
The CoreGraphQLQuery object gets created, or the user gets a proper error message.
Steps to Reproduce
Additional Information
The error message seems to be related to the fact we want to index the "query" attribute value. Not sure if that makes a lot of sense in the context of a GraphQLQuery.