question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redis GEO related error: ERR unsupported unit provided. please use m, km, ft, mi

See original GitHub issue

Describe the bug

I tried to use redis GEO commands geoadd/geodist/geosearch via Quarks v2.12 but got the below error which is nearly the same with the one I mistake to operate redis via redis-cli.

Sep 09, 2022 8:52:54 AM org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext handleUnrecoverableError
ERROR: Request failed
java.util.concurrent.CompletionException: ERR unsupported unit provided. please use m, km, ft, mi
	at io.smallrye.mutiny.operators.uni.UniBlockingAwait.await(UniBlockingAwait.java:79)
	at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:65)
	at io.quarkus.redis.runtime.datasource.BlockingGeoCommandsImpl.geosearch(BlockingGeoCommandsImpl.java:155)
	at com.edwin.quarkus.service.RedisTool.geoSearch(RedisTool.java:65)
	at com.edwin.quarkus.service.RedisTool_Subclass.geoSearch$$superforward1(Unknown Source)
	at com.edwin.quarkus.service.RedisTool_Subclass$$function$$3.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:40)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at com.edwin.quarkus.service.RedisTool_Subclass.geoSearch(Unknown Source)
	at com.edwin.quarkus.service.RedisTool_ClientProxy.geoSearch(Unknown Source)
	at com.edwin.quarkus.controller.RestController.fetchAcceList(RestController.java:43)
	at com.edwin.quarkus.controller.RestController_Subclass.fetchAcceList$$superforward1(Unknown Source)
	at com.edwin.quarkus.controller.RestController_Subclass$$function$$1.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:53)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
	at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:40)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at com.edwin.quarkus.controller.RestController_Subclass.fetchAcceList(Unknown Source)
	at com.edwin.quarkus.controller.RestController$quarkusrestinvoker$fetchAcceList_0ac711ca01189983132bf14b86d98a463c50a566.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:108)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:140)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:557)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: ERR unsupported unit provided. please use m, km, ft, mi
10.18.222.16:7000> GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
-> Redirected to slot [10713] located at 10.18.222.16:7003
(integer) 2
10.18.222.16:7003> GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
(integer) 0
10.18.222.16:7003> GEODIST Sicily Palermo Catania
"166274.1516"
10.18.222.16:7003> GEORADIUS Sicily 15 37 100 km
1) "Catania"
10.18.222.16:7003> GEORADIUS Sicily 15 37 200 km
1) "Palermo"
2) "Catania"
10.18.222.16:7003> GEORADIUS Sicily 15 37 100 KM
(error) ERR unsupported unit provided. please use m, km, ft, mi
10.18.222.16:7003> GEORADIUS Sicily 15 37 100 km
1) "Catania"
10.18.222.16:7003>

My code:

RedisTool

package com.edwin.quarkus.service;

import io.quarkus.redis.datasource.RedisDataSource;
import io.quarkus.redis.datasource.geo.GeoCommands;
import io.quarkus.redis.datasource.geo.GeoSearchArgs;
import io.quarkus.redis.datasource.geo.GeoUnit;
import io.quarkus.redis.datasource.geo.GeoValue;
import io.quarkus.redis.datasource.keys.KeyCommands;
import io.quarkus.redis.datasource.string.StringCommands;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.util.List;
import java.util.OptionalDouble;

@ApplicationScoped
public class RedisTool {
    @Inject
    RedisDataSource redisDataSource;

    private KeyCommands<String> keyCommands;
    private StringCommands<String, String> stringCommands;

    private GeoCommands<String, String> geoCommands;

    @PostConstruct
    void init(){
        keyCommands = redisDataSource.key();
        stringCommands = redisDataSource.string(String.class);
        geoCommands = redisDataSource.geo(String.class, String.class);
    }

    public void del(String key) {
        keyCommands.del(key);
    }

    public String get(String key) {
        return stringCommands.get(key);
    }

    public void set(String key, String value) {
        stringCommands.set(key, value);
    }

    public void geoAdd(String key, double longitude, double latitude, String memberName){
        geoCommands.geoadd(key, longitude, latitude, memberName);
    }

    public double geoDist(String key, String memberNameFrom, String memberNameTo){
        OptionalDouble result = geoCommands.geodist(key, memberNameFrom, memberNameTo, GeoUnit.KM);
        if(result.isPresent()){
            return result.getAsDouble();
        }else{
            return 0.0;
        }
    }

    public List<GeoValue<String>> geoSearch(String key, String memberName, double radius){
        GeoSearchArgs args = new GeoSearchArgs<>();
        args.fromMember(memberName);
        args.byRadius(radius, GeoUnit.KM);
        args.count(10);
        args.ascending();
        List<GeoValue<String>> nearList = geoCommands.geosearch(key, args);
        return nearList;
    }
}
    @POST
    @Path(value="/v1/zzz")
    @Produces(MediaType.APPLICATION_JSON+";charset=UTF-8")
    @Consumes(MediaType.APPLICATION_JSON+";charset=UTF-8")
    public String fetchAcceList(FetchAcceListParam fetchAcceListParam,
                                @Context io.vertx.core.http.HttpServerRequest httpRequest) throws Exception {
        redisTool.geoAdd("zzz", 13.361389, 38.115556, "Palermo");
        redisTool.geoAdd("zzz", 15.087269, 37.502669, "Catania");

        System.out.println(redisTool.geoDist("zzz", "Palermo", "Catania"));
        System.out.println(redisTool.geoSearch("zzz", "Palermo", 500.0));

        return "";
    }

application.yml

quarkus:
  http:
    port: 18087
    root-path: /
  redis:
    hosts: redis://xxx.yyy.zzz.ab:7000,redis://xxx.yyy.zzz.ab7001,redis://xxx.yyy.zzz.ab:7002,redis://xxx.yyy.zzz.ab:7003,redis://xxx.yyy.zzz.ab7004,redis://xxx.yyy.zzz.ab:7005
    password: ******
    timeout: 10s
    client-type: cluster
    replicas: share
    max-pool-size: 20
    max-pool-waiting: 24
    pool-cleaner-interval: 5s
    pool-recycle-timeout: 15s
    max-waiting-handlers: 2048
    max-nested-arrays: 16
    reconnect-interval: 30s

Expected behavior

Return the nearist member in the given key.

Actual behavior

Return error: Caused by: ERR unsupported unit provided. please use m, km, ft, mi

How to Reproduce?

Just run the code I offered.

Output of uname -a or ver

Linux a176656f74a6 5.4.0-117-generic

Output of java -version

openjdk version “11.0.11” 2021-04-20

GraalVM version (if different from Java)

graalvm-ce-java11-21.3.0

Quarkus version or git rev

2.12.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

3.8.1

Additional information

I guess the unit of io.quarkus.redis.datasource.geo.GeoUnit should be lower case?

package io.quarkus.redis.datasource.geo;

public enum GeoUnit {

    /**
     * meter.
     */
    M, // Should all be lower case?

    /**
     * kilometer.
     */
    KM,

    /**
     * feet.
     */
    FT,

    /**
     * mile.
     */
    MI;
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cescoffiercommented, Sep 10, 2022

Yes, I will have a look. Hoping that lowercase would work everywhere.

0reactions
iedwincommented, Sep 14, 2022

Tested GEO commands(geoadd/geodist/geosearch) by runing quarkus v2.12.2.Final on redis cluster 6.2.6 and 7.0.4. All worked well. Thanks again for your quick fix! @cescoffier

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis client for Golang - Go Packages
Redis `GET key` command. It returns redis.Nil error when key does not exist. func (*ClusterClient) GetBit ¶. func ( ...
Read more >
redis-py 4.0.0 documentation
Returns an active Redis client generated from the given database URL. ... The units must be one of the following : m, km...
Read more >
Quarkus 2.12.2.Final released! - Backend News - Devtalk
... Redis 6; #27858 - Add link to Mutiny guide; #27831 - Redis GEO related error: ERR unsupported unit provided. please use m,...
Read more >
redis-py-cluster Documentation - Read the Docs
To find out what options redis-py provides please consult the documentation ... [NYV] - GEORADIUS key longitude latitude radius m|km|ft|mi ...
Read more >
Untitled
#Ajukan kartu kredit bank mega, Bollywood movies tv7, Net tools 5 64 bit, Ukraine 1932-33, Canalul periboina, M phil in ignou 2016, Conrad...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found