This topic describes the common issues that may occur when you use OBKV-Table, including their causes and solutions.
Common issues in the IDEA development tool
ObTableClient JAR file missing
Exception in thread "main" java.lang.NoClassDefFoundError: com/alipay/oceanbase/rpc/ObTableClient
at com.oceanbase.example.KVClient.initial(KVClient.java:46)
at com.oceanbase.example.SimpleKVDemo.main(SimpleKVDemo.java:25)
Caused by: java.lang.ClassNotFoundException: com.alipay.oceanbase.rpc.ObTableClient
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 2 more
Process finished with exit code 1
Cause
The
obkv-table-clientdependency specified in thepom.xmlproject file is missing. This may be because the dependency has not been downloaded to the local Maven repository. The full path of the client JAR file is:~/.m2/repository/com/oceanbase/obkv-table-client/0.1.0/obkv-table-client-0.1.0.jarSolution
You can check whether the local repository address is configured in IDEA as shown in the following figure.
Java client initialization failed
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Sofa-Middleware-Log:WARN [oceanbase-table-client] No log util is usable, Default app logger will be used.
... ...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'proxyro'@'xxx.xxx.xxx.xxx' (using password: YES)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
... ...
Cause
In the example, no password is set for the proxyro user. That is, no password is set for the user specified by the
setSysUserNamefunction during client initialization.obTableClient.setSysUserName("proxyro@sys"); // e.g. proxyro@sys obTableClient.setSysPassword("proxyro@passwd");Solution
You can log in to the OceanBase AI Database cluster by using OBClient or the MySQL client, and then run the following command to set a password for the proxyro user. For more information, see Connect to OceanBase AI Database by using OBClient and Connect to OceanBase AI Database by using the MySQL client.
grant select on oceanbase.* to proxyro identified by 'xxx'; // 'xxx' is the password, which you can set as needed.
Database is empty
java.lang.IllegalArgumentException: database is empty. url=http://ip:port/services?Action=ObRootServiceInfo&User_ID=admin&UID=admin&ObRegion=ocp
at com.alipay.oceanbase.rpc.ObTableClient.setParamURL(ObTableClient.java:1396)
at com.oceanbase.example.KVClient.initial(KVClient.java:48)
at com.oceanbase.example.SimpleKVDemo.main(SimpleKVDemo.java:25)
fail to init KV client, java.lang.IllegalArgumentException: database is empty. url=http://ip:port/services?Action=ObRootServiceInfo&User_ID=admin&UID=admin&ObRegion=ocp
Cause
No database is specified in the input URL of the
setParamURLfunction when the Java client is initialized.Solution
You can specify the database to access in the URL.
obTableClient.setParamURL("http://ip:port/services?Action=ObRootServiceInfo&User_ID=xxx&UID=xxx&ObRegion=xxx&database=test");
Table does not exist
com.alipay.oceanbase.rpc.exception.ObTableNotExistException: table not exist: kv_table
at com.alipay.oceanbase.rpc.location.LocationUtil.getTableEntryFromResultSet(LocationUtil.java:622)
at com.alipay.oceanbase.rpc.location.LocationUtil.getTableEntryFromRemote(LocationUtil.java:384)
at com.alipay.oceanbase.rpc.location.LocationUtil.access$200(LocationUtil.java:50)
at com.alipay.oceanbase.rpc.location.LocationUtil$1$1.execute(LocationUtil.java:313)
at com.alipay.oceanbase.rpc.location.LocationUtil$1$1.execute(LocationUtil.java:309)
at com.alipay.oceanbase.rpc.location.LocationUtil.callTableEntryRefresh(LocationUtil.java:264)
at com.alipay.oceanbase.rpc.location.LocationUtil.access$300(LocationUtil.java:50)
at com.alipay.oceanbase.rpc.location.LocationUtil$1.execute(LocationUtil.java:308)
at com.alipay.oceanbase.rpc.location.LocationUtil$1.execute(LocationUtil.java:305)
at com.alipay.oceanbase.rpc.location.LocationUtil.callTableEntryRefreshWithPriority(LocationUtil.java:133)
at com.alipay.oceanbase.rpc.location.LocationUtil.loadTableEntryWithPriority(LocationUtil.java:304)
at com.alipay.oceanbase.rpc.ObTableClient.refreshTableEntry(ObTableClient.java:753)
at com.alipay.oceanbase.rpc.ObTableClient.getOrRefreshTableEntry(ObTableClient.java:702)
at com.alipay.oceanbase.rpc.ObTableClient.getTable(ObTableClient.java:839)
at com.alipay.oceanbase.rpc.ObTableClient.execute(ObTableClient.java:424)
at com.alipay.oceanbase.rpc.ObTableClient.execute(ObTableClient.java:400)
at com.alipay.oceanbase.rpc.ObTableClient.insert(ObTableClient.java:1060)
at com.alipay.oceanbase.rpc.table.AbstractTable.insert(AbstractTable.java:52)
at com.oceanbase.example.KVClient.put(KVClient.java:81)
at com.oceanbase.example.SimpleKVDemo.main(SimpleKVDemo.java:40)
fail to put kv data, com.alipay.oceanbase.rpc.exception.ObTableNotExistException: table not exist: kv_table
Cause
The
kv_tabletable does not exist in the database specified bysetParamURL.Notice
kv_tableis the table name that returns an error in the example. It is for reference only. The actual table name may differ.Solution
Make sure that the table operated by the client API exists in the database specified by
setParamURL.
Common issues in command-line development
Dependency packages such as sofa cannot be found
$mvn compile -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building simple-kv-demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.oceanbase:obkv-table-client:jar:0.1.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ simple-kv-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ simple-kv-demo ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /home/admin/github/obkv-table-client-java/example/simple-kv-demo/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[21,35] package com.alipay.sofa.common.code does not exist
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[22,34] package com.alipay.sofa.common.log does not exist
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[23,17] package org.slf4j does not exist
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[28,19] cannot find symbol
symbol: class LogCode2Description
location: class com.oceanbase.example.LoggerFactory
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[31,19] cannot find symbol
symbol: class Logger
location: class com.oceanbase.example.LoggerFactory
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[38,19] cannot find symbol
symbol: class Logger
location: class com.oceanbase.example.LoggerFactory
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[28,45] cannot find symbol
symbol: variable LogCode2Description
location: class com.oceanbase.example.LoggerFactory
[ERROR] /home/admin/github/obkv-table-client-java/example/simple-kv-demo/src/main/java/com/oceanbase/example/LoggerFactory.java:[35,16] cannot find symbol
symbol: variable LoggerSpaceManager
location: class com.oceanbase.example.LoggerFactory
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project simple-kv-demo: Compilation failure
at org.apache.maven.lifecycle.internal.MojoE
Cause
The JAR file that
pom.xmldepends on at the local path may not be the latest version.Solution
You can clear the local Maven repository package that the project depends on, and then compile the project again.
mvn dependency:purge-local-repository
Considerations
If you directly use the demo project on the official website of GitHub for debugging, package all dependencies of the demo project before execution. To package all dependencies, you must modify the pom.xml file of the demo project.
Take obkv-table-client-java/example/simple-kv-demo as an example, add the following content to the pom.xml file:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.oceanbase.example.SimpleKVDemo</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Compile the package again after modification:
mvn clean package
Run the following command:
java -cp ./target/simple-kv-demo-1.0-SNAPSHOT-jar-with-dependencies.jar com.oceanbase.example.SimpleKVDemo
Note
For more information about how to use the client, see the example demo project.
Monitoring FAQ
Are histograms available for OBKV-Table monitoring metrics?
OBKV-Table supports histograms for viewing performance metrics such as P99. You can query the V$OB_QUERY_RESPONSE_TIME_HISTOGRAM view and combine it with Prometheus statistics to obtain performance metrics such as P95 and P99 for various operations.
For more information about this view, see V$OB_QUERY_RESPONSE_TIME_HISTOGRAM.