tarantool / cartridge-springdata

Spring Data Tarantool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No exception during call of lua-function (with Optional result) when Tarantool unavailable

andrei-punko opened this issue · comments

During call of spring-data function deleteByAuthKey() of next repository:

@Repository
public interface PortfolioTarantoolRepository extends TarantoolRepository<PortfolioEntity, String> {
    @Query(function = "delete_by_auth_key")
    Optional<PortfolioEntity> deleteByAuthKey(String authKey);
}

when Tarantool unavailable (service started with wrong Tarantool address)
we don't receive any exception/errors in logs.

Hi, @andrei-punko!
I tried to reproduce the problem, but it didn't work. I tried to specify not correct address in the settings and turn it off on the fly. And in the first case, it immediately throws an exception, in the second i received java.util.concurrent.TimeoutException: Failed to receive a response to request 5 within 5000 ms - it timed out.
Can you give more information about the configuration and what is happened on the Tarantool side in Lua code?

Our configuration on java side:

@Configuration("tarantoolConfiguration")
public class TarantoolConfig extends AbstractTarantoolDataConfiguration {
    @Value("${tarantool.address}")
    private String address;

    @Value("${tarantool.username}")
    private String username;

    @Value("${tarantool.password}")
    private String password;

    @Override
    protected TarantoolServerAddress tarantoolServerAddress() {
        return new TarantoolServerAddress(address);
    }

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

    @Override
    public TarantoolClient<TarantoolTuple, TarantoolResult<TarantoolTuple>> tarantoolClient(
            TarantoolClientConfig tarantoolClientConfig,
            TarantoolClusterAddressProvider tarantoolClusterAddressProvider
    ) {
        ProxyTarantoolTupleClient proxyClient =
                new ProxyTarantoolTupleClient(super.tarantoolClient(tarantoolClientConfig, tarantoolClusterAddressProvider));
        return new RetryingTarantoolTupleClient(proxyClient, requestRetryPolicyFactory());
    }

    @Bean
    public RequestRetryPolicyFactory requestRetryPolicyFactory() {
        return TarantoolRequestRetryPolicies
                .byNumberOfAttempts(0)
                .build();
    }
}

Not important what happened on Tarantool side when wrong url used

After discussion with customer we cleared up the problem.
It's required to check that tarantool connections are available on service start.
The proposed solution is to use synchronous call to client.getVersion() on startup.