Bug Type (问题类型)
gremlin (unexpected result)
Before submit
Environment (环境信息)
- HugeGraph Server: current
apache/hugegraph master at 431f6e6b
- TinkerPop: 3.5.1
- Backend: backend-independent; the incorrect rewrite happens in a traversal strategy before the vertex is written
Expected and actual behavior (期望与实际表现)
HugePrimaryKeyStrategy folds a single-cardinality AddPropertyStep immediately following addV() into the vertex-creation step.
For this traversal:
g.addV("person").
property("name", "marko", "country", "cn")
TinkerPop treats country=cn as a meta-property attached to the name vertex property. It does not treat country as a sibling property of the vertex.
HugeGraph currently reports supportsMetaProperties() == false, and HugeVertex.property(...) explicitly throws VertexProperty.Exceptions.metaPropertiesNotSupported() when meta-properties are passed. The expected behavior is therefore an explicit rejection.
The optimization changes that behavior. HugePrimaryKeyStrategy copies every AddPropertyStep parameter other than T.key and T.value into the addV() configuration, then removes the original AddPropertyStep. If country is also a valid schema property, HugeGraph can silently create an ordinary vertex property country=cn instead of rejecting the unsupported meta-property.
This is a data-semantics problem because an unsupported construct is accepted with a different meaning.
Minimal reproduction
Create a schema in which both keys are valid ordinary vertex properties:
schema = graph.schema()
schema.propertyKey("name").asText().create()
schema.propertyKey("country").asText().create()
schema.vertexLabel("person").
properties("name", "country").
primaryKeys("name").
create()
Run the traversal and inspect the resulting vertex:
g.addV("person").
property("name", "marko", "country", "cn").
iterate()
g.V().hasLabel("person").has("name", "marko").valueMap(true)
Expected:
- The write is rejected with
metaPropertiesNotSupported().
country=cn is never stored as an ordinary vertex property.
Actual on the affected strategy path:
- The
AddPropertyStep is removed.
country=cn is folded into the vertex-creation step as an ordinary vertex property.
A strategy-level reproduction shows the rewritten traversal as:
AddVertexStartStep({country=[cn], label=[person], name=[marko]})
Source analysis
The strategy was introduced in 4b74ab6c in March 2023. The same behavior is still present on the current public master branch. It was noticed while reviewing a TinkerPop 3.8.1 adaptation, but it is not introduced by that upgrade.
Suggested fix and acceptance criteria
When an AddPropertyStep contains vertex-property metadata, HugePrimaryKeyStrategy should not fold that step into addV(). Leaving the step in place preserves the existing explicit rejection from HugeVertex.property(...).
A regression test should verify that:
- The traversal above throws the unsupported-meta-property exception.
- The metadata key is never written as an ordinary vertex property.
- Normal
addV().property(key, value) folding still works.
- Both
AddVertexStartStep and mid-traversal AddVertexStep paths preserve the same behavior.
Bug Type (问题类型)
gremlin (unexpected result)
Before submit
Environment (环境信息)
apache/hugegraphmasterat431f6e6bExpected and actual behavior (期望与实际表现)
HugePrimaryKeyStrategyfolds a single-cardinalityAddPropertyStepimmediately followingaddV()into the vertex-creation step.For this traversal:
TinkerPop treats
country=cnas a meta-property attached to thenamevertex property. It does not treatcountryas a sibling property of the vertex.HugeGraph currently reports
supportsMetaProperties() == false, andHugeVertex.property(...)explicitly throwsVertexProperty.Exceptions.metaPropertiesNotSupported()when meta-properties are passed. The expected behavior is therefore an explicit rejection.The optimization changes that behavior.
HugePrimaryKeyStrategycopies everyAddPropertyStepparameter other thanT.keyandT.valueinto theaddV()configuration, then removes the originalAddPropertyStep. Ifcountryis also a valid schema property, HugeGraph can silently create an ordinary vertex propertycountry=cninstead of rejecting the unsupported meta-property.This is a data-semantics problem because an unsupported construct is accepted with a different meaning.
Minimal reproduction
Create a schema in which both keys are valid ordinary vertex properties:
Run the traversal and inspect the resulting vertex:
Expected:
metaPropertiesNotSupported().country=cnis never stored as an ordinary vertex property.Actual on the affected strategy path:
AddPropertyStepis removed.country=cnis folded into the vertex-creation step as an ordinary vertex property.A strategy-level reproduction shows the rewritten traversal as:
Source analysis
AddPropertyStepseparatesT.keyandT.valuefrom the remaining vertex-property key/value pairs, then passes the remaining pairs toVertex.property(...)as meta-properties.HugeVertex.property(...)rejects them.HugePrimaryKeyStrategychanges the remaining pairs intoaddV()parameters.The strategy was introduced in
4b74ab6cin March 2023. The same behavior is still present on the current publicmasterbranch. It was noticed while reviewing a TinkerPop 3.8.1 adaptation, but it is not introduced by that upgrade.Suggested fix and acceptance criteria
When an
AddPropertyStepcontains vertex-property metadata,HugePrimaryKeyStrategyshould not fold that step intoaddV(). Leaving the step in place preserves the existing explicit rejection fromHugeVertex.property(...).A regression test should verify that:
addV().property(key, value)folding still works.AddVertexStartStepand mid-traversalAddVertexSteppaths preserve the same behavior.