-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add system schema store #1891
Add system schema store #1891
Conversation
ace9831
to
de95390
Compare
Codecov Report
@@ Coverage Diff @@
## master #1891 +/- ##
============================================
+ Coverage 71.02% 71.08% +0.05%
+ Complexity 982 963 -19
============================================
Files 451 452 +1
Lines 38206 38405 +199
Branches 5407 5418 +11
============================================
+ Hits 27136 27299 +163
- Misses 8420 8447 +27
- Partials 2650 2659 +9
Continue to review full report at Codecov.
|
Add meta table into system store Add test case for read version Let AbstractBackendStore impl default storedVersion() fix small bug og HugeProject add test for SystemSchemaStore Change-Id: I5c9d65c4ae022cb84592e8f2aa57bd7485cd12e4
...graph-core/src/main/java/com/baidu/hugegraph/backend/store/AbstractBackendStoreProvider.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendStoreProvider.java
Outdated
Show resolved
Hide resolved
@@ -70,12 +72,16 @@ | |||
public class SchemaTransaction extends IndexableTransaction { | |||
|
|||
private final SchemaIndexTransaction indexTx; | |||
private final SystemSchemaStore systemSchemaStore; | |||
private final LocalCounter counter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: move LocalCounter counter
define into SystemSchemaStore class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalCounter provider by HugegraphParams, if we move it to SystemSchemaStore, maybe change too much code
hugegraph-dist/src/main/java/com/baidu/hugegraph/cmd/InitStore.java
Outdated
Show resolved
Hide resolved
@@ -25,9 +25,11 @@ | |||
public abstract class AbstractBackendStore<Session extends BackendSession> | |||
implements BackendStore { | |||
|
|||
private final SystemSchemaStore systemSchemaStore; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: move SystemSchemaStore into backend like MetaStore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this TODO annotation it first
public BackendStoreInfo backendStoreInfo() { | ||
// Just for trigger Tx.getOrNewTransaction, then load 3 stores | ||
this.systemTransaction(); | ||
return new BackendStoreInfo(this.configuration, this.storeProvider); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: pass storeProvider.metaStore()
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/SchemaTransaction.java
Show resolved
Hide resolved
mysql ci: Error: Tests run: 728, Failures: 0, Errors: 2, Skipped: 36, Time elapsed: 372.603 s <<< FAILURE! - in com.baidu.hugegraph.core.CoreTestSuite
Error: testCreateGraphsWithSameName(com.baidu.hugegraph.core.MultiGraphsTest) Time elapsed: 0.436 s <<< ERROR!
com.baidu.hugegraph.backend.BackendException: Failed to insert driver version with 'INSERT INTO m VALUES ('VERSION', '1.11')'
at com.baidu.hugegraph.core.MultiGraphsTest.testCreateGraphsWithSameName(MultiGraphsTest.java:263)
Error: testWriteAndReadVersion(com.baidu.hugegraph.core.MultiGraphsTest) Time elapsed: 0.206 s <<< ERROR!
com.baidu.hugegraph.backend.BackendException: Failed to insert driver version with 'INSERT INTO m VALUES ('VERSION', '1.11')'
at com.baidu.hugegraph.core.MultiGraphsTest.testWriteAndReadVersion(MultiGraphsTest.java:65) |
hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTables.java
Outdated
Show resolved
Hide resolved
driverVersion); | ||
try { | ||
session.execute(insert); | ||
} catch (SQLException throwables) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to SQLException e
and pass into BackendException
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method sign is session.execute() throw SQLException, so we can't change to BackendException
versionColumn); | ||
try { | ||
session.execute(insert); | ||
} catch (SQLException throwables) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
ci error during init-store: Error: Exception in thread "main" java.lang.IllegalArgumentException: Undefined vertex label: '~user'
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:163)
at com.baidu.hugegraph.util.E.checkArgument(E.java:56)
at com.baidu.hugegraph.StandardHugeGraph.vertexLabel(StandardHugeGraph.java:793)
at com.baidu.hugegraph.auth.HugeGraphAuthProxy.lambda$vertexLabel$2(HugeGraphAuthProxy.java:259)
at com.baidu.hugegraph.auth.HugeGraphAuthProxy.lambda$verifySchemaPermission$24(HugeGraphAuthProxy.java:914)
at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:939)
at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifyResPermission(HugeGraphAuthProxy.java:925)
at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifySchemaPermission(HugeGraphAuthProxy.java:912)
at com.baidu.hugegraph.auth.HugeGraphAuthProxy.verifySchemaPermission(HugeGraphAuthProxy.java:905)
at com.baidu.hugegraph.auth.HugeGraphAuthProxy.vertexLabel(HugeGraphAuthProxy.java:258)
at com.baidu.hugegraph.auth.EntityManager.queryEntity(EntityManager.java:154)
at com.baidu.hugegraph.auth.EntityManager.query(EntityManager.java:136)
at com.baidu.hugegraph.auth.StandardAuthManager.findUser(StandardAuthManager.java:177)
at com.baidu.hugegraph.auth.StandardAuthenticator.requireInitAdminUser(StandardAuthenticator.java:77)
at com.baidu.hugegraph.auth.StandardAuthenticator.initAdminUser(StandardAuthenticator.java:52)
at com.baidu.hugegraph.auth.StandardAuthenticator.initAdminUserIfNeeded(StandardAuthenticator.java:191)
at com.baidu.hugegraph.cmd.InitStore.main(InitStore.java:91) |
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.baidu.hugegraph.testutil.Assert; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
import jakarta.ws.rs.core.Response; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems can remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it had been used, so we can't remove
hugegraph-test/src/main/java/com/baidu/hugegraph/unit/UnitTestSuite.java
Outdated
Show resolved
Hide resolved
...raph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraStore.java
Outdated
Show resolved
Hide resolved
...raph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraStore.java
Outdated
Show resolved
Hide resolved
...raph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraStore.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/schema/VertexLabel.java
Outdated
Show resolved
Hide resolved
hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlStore.java
Outdated
Show resolved
Hide resolved
@@ -998,6 +998,12 @@ public HugeGraph graph() { | |||
return this.taskScheduler.graph(); | |||
} | |||
|
|||
@Override | |||
public void init() { | |||
verifyAdminPermission(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.verifyAdminPermission()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method doesn't use this, the code is in inner class TaskSchedulerProxy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get it
@@ -1161,6 +1167,12 @@ private String currentUsername() { | |||
return null; | |||
} | |||
|
|||
@Override | |||
public void init() { | |||
verifyAdminPermission(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is inner class AuthManagerProxy, so can't use this.
hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBStore.java
Outdated
Show resolved
Hide resolved
hugegraph-rocksdb/src/main/java/com/baidu/hugegraph/backend/store/rocksdb/RocksDBStore.java
Outdated
Show resolved
Hide resolved
String driverVersion = this.provider().driverVersion(); | ||
this.meta.writeVersion(session, driverVersion); | ||
this.meta.writeVersion(this.session(), driverVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "this.checkOpened()" since called in this.session()
@@ -578,7 +574,7 @@ protected List<String> tableNames() { | |||
public void init() { | |||
super.init(); | |||
super.checkOpened(); | |||
Session session = super.getSession(); | |||
Session session = super.sessions.session(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can call this.session(null)
, and we can also replace the following code with
Session session = this.session(null)
like line 228,477:
this.checkOpened();
Session session = this.sessions.session();
@@ -1118,8 +1114,7 @@ public synchronized void init() { | |||
Lock writeLock = this.storeLock().writeLock(); | |||
writeLock.lock(); | |||
try { | |||
super.checkOpened(); | |||
Session session = super.getSession(); | |||
Session session = super.sessions.session(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can call this.session(HugeType.META)
@@ -800,14 +795,13 @@ public void init() { | |||
super.init(); | |||
this.checkOpened(); | |||
String driverVersion = this.provider().driverVersion(); | |||
this.meta.writeVersion(this.session(), driverVersion); | |||
this.meta.writeVersion(this.session(null), driverVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this.checkOpened() call.
also update other unused call "checkOpened()"?
@@ -1129,7 +1129,7 @@ public String storedVersion() { | |||
readLock.lock(); | |||
try { | |||
super.checkOpened(); | |||
Session session = super.sessions.session(); | |||
Session session = super.session(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this.checkOpened() call
@@ -1114,7 +1114,7 @@ public synchronized void init() { | |||
Lock writeLock = this.storeLock().writeLock(); | |||
writeLock.lock(); | |||
try { | |||
Session session = super.sessions.session(); | |||
Session session = super.session(HugeType.META); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.session(HugeType.META);
@@ -1129,7 +1129,7 @@ public String storedVersion() { | |||
readLock.lock(); | |||
try { | |||
super.checkOpened(); | |||
Session session = super.sessions.session(); | |||
Session session = super.session(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep this.session(HugeType.META)
@@ -573,17 +573,15 @@ protected List<String> tableNames() { | |||
@Override | |||
public void init() { | |||
super.init(); | |||
super.checkOpened(); | |||
Session session = super.sessions.session(); | |||
Session session = super.session(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep this.session(null) style?
also update other "super.session("?
@@ -998,6 +998,12 @@ public HugeGraph graph() { | |||
return this.taskScheduler.graph(); | |||
} | |||
|
|||
@Override | |||
public void init() { | |||
verifyAdminPermission(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get it
@Override | ||
public void init() { | ||
super.init(); | ||
this.checkOpened(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
fix #1533
Add system schema store
Add meta table into system store
Add test case for read version
Let AbstractBackendStore impl default storedVersion()