Search code examples
javatarantool

when selecting data from the storage, an exception is thrown 'Procedure 'ddl.get_schema' is not defined'


I created the users space:

s = box.schema.space.create('users')
s:format({                          
         > {name = 'id', type = 'unsigned'},
         > {name = 'user_name', type = 'string'},
         > {name = 'age', type = 'unsigned'}
         > })

I have entity User:

@Tuple(spaceName = "users")
public class User {

    @Id
    private Long id;

    @Field(name = "user_name")
    private String name;

    private Long age;
}

DB connection settings:

@Configuration
@EnableTarantoolRepositories(basePackageClasses = UserRepository.class)
public class TarantoolConfiguration extends AbstractTarantoolDataConfiguration {

    @Value("${tarantool.host}")
    protected String host;
    @Value("${tarantool.port}")
    protected int port;
    @Value("${tarantool.username}")
    protected String username;
    @Value("${tarantool.password}")
    protected String password;

    @Override
    protected TarantoolServerAddress tarantoolServerAddress() {
        return new TarantoolServerAddress(host, port);
    }

    @Override
    public TarantoolCredentials tarantoolCredentials() {
        return new SimpleTarantoolCredentials(username, password);
    }

    @Override
    public TarantoolClient tarantoolClient(TarantoolClientConfig tarantoolClientConfig,
                                           TarantoolClusterAddressProvider tarantoolClusterAddressProvider) {
        return new ProxyTarantoolTupleClient(super.tarantoolClient(tarantoolClientConfig, tarantoolClusterAddressProvider));
    }
}

There is also an endpoint that simply displays a list of users:

 @GetMapping("/users")
    public List<User> getUsers() {
        return (List<User>) userRepository.findAll();
    }

When accessing the address http://localhost:8080/users throws exception:

ERROR 2203 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is io.tarantool.driver.exceptions.TarantoolClientException: Failed to refresh spaces and indexes metadata] with root cause

io.tarantool.driver.exceptions.TarantoolServerException: TarantoolServerException: code=32801, message=Procedure 'ddl.get_schema' is not defined
    at 

What could be the problem?


Solution

  • The cartridge-java driver needs the spaces and indexes schemas for validation and other purposes. Currently, the necessary metadata is fetched immediately after a connection is established. Since the connection initialization is lazy, it actually happens on the first request to the Tarantool server.

    The driver allows connecting both to a standalone Tarantool replica set and to a Tarantool Cartridge cluster. It seems that you're using a standalone Tarantool instance. In that case, all operations with the server are expected to be performed directly with the instance the driver is connected to. So, there is no need to use the ProxyTarantoolTupleClient, and you may simply omit the overloading of the tarantoolClient method in the configuration.

    More information about connecting to the cluster and standalone instances is available in the driver's README. Check out also our Pet Clinic example for Tarantool.