Skip to content

fix(server): ensure backend is initialized in gremlin script#2824

Merged
VGalaxies merged 1 commit intoapache:masterfrom
zmrlft:fix-gremlin-rocksdb
Jul 3, 2025
Merged

fix(server): ensure backend is initialized in gremlin script#2824
VGalaxies merged 1 commit intoapache:masterfrom
zmrlft:fix-gremlin-rocksdb

Conversation

@zmrlft
Copy link
Contributor

@zmrlft zmrlft commented Jun 29, 2025

Purpose of the PR

Main Changes

The fundamental reason is that HugeFactory.open () returns an instance of StandardHugeGraph, but its backend storage has not been initialized yet. I added initBackend below for initialization

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • xxx

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 29, 2025
@zmrlft zmrlft force-pushed the fix-gremlin-rocksdb branch 3 times, most recently from 34598e4 to a23d1d0 Compare June 30, 2025 02:08
@codecov
Copy link

codecov bot commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 0.08%. Comparing base (e139465) to head (a23d1d0).

Files with missing lines Patch % Lines
...n/java/org/apache/hugegraph/StandardHugeGraph.java 0.00% 4 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (e139465) and HEAD (a23d1d0). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (e139465) HEAD (a23d1d0)
4 1
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #2824       +/-   ##
============================================
- Coverage     42.87%   0.08%   -42.79%     
+ Complexity      458      22      -436     
============================================
  Files           758     725       -33     
  Lines         61313   57652     -3661     
  Branches       7877    7232      -645     
============================================
- Hits          26286      51    -26235     
- Misses        32311   57599    +25288     
+ Partials       2716       2     -2714     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VGalaxies
Copy link
Contributor

VGalaxies commented Jun 30, 2025

@zmrlft Maybe directly modifying https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/src/assembly/static/scripts/example.groovy might be a better idea? I'm not sure if initializing the backend in the constructor could have some potential side effects.

cc @imbajin

@VGalaxies VGalaxies requested a review from Copilot June 30, 2025 08:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that the backend stores are initialized when a StandardHugeGraph instance is created by calling each store’s open(...) and the storeProvider.init() in the constructor.

  • Added explicit calls to open schema, system, and graph stores
  • Initialized the storeProvider immediately after store opens
Comments suppressed due to low confidence (1)

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java:249

  • Consider adding a unit test that constructs StandardHugeGraph and verifies the stores are open and storeProvider is initialized to prevent regressions.
            this.loadSchemaStore().open(this.configuration);


try {

this.loadSchemaStore().open(this.configuration);
Copy link

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] These sequential store open calls and storeProvider.init() could be extracted into a private initBackend() helper to improve readability and avoid constructor bloat.

Copilot uses AI. Check for mistakes.
@zmrlft
Copy link
Contributor Author

zmrlft commented Jun 30, 2025

@zmrlft Maybe directly modifying https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/src/assembly/static/scripts/example.groovy might be a better idea? I'm not sure if initializing the backend in the constructor could have some potential side effects.

cc @imbajin

Yes, what you said makes sense! I will consider it. If the constructor of StandardHugeGraph is modified, it is indeed very likely to cause other problems

@zmrlft zmrlft force-pushed the fix-gremlin-rocksdb branch from a23d1d0 to 1b19f27 Compare June 30, 2025 12:24
@zmrlft zmrlft changed the title fix(server): ensure backend is initialized in StandardHugeGraph const… fix(server): ensure backend is initialized in gremlin script Jun 30, 2025
@zmrlft zmrlft force-pushed the fix-gremlin-rocksdb branch from 1b19f27 to 311dd08 Compare June 30, 2025 14:08
Copy link
Member

@imbajin imbajin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX~

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 1, 2025
@imbajin imbajin requested a review from VGalaxies July 1, 2025 10:20
Copy link
Contributor

@Pengzna Pengzna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VGalaxies PTAL

@VGalaxies VGalaxies merged commit a53af86 into apache:master Jul 3, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] gremlin example script execution error with RocksDB backend

5 participants