Skip to content
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

first query result contains a wrong string field null value #5177

Closed
bocai3030 opened this issue Jan 2, 2023 · 7 comments
Closed

first query result contains a wrong string field null value #5177

bocai3030 opened this issue Jan 2, 2023 · 7 comments
Assignees
Labels
affects/none PR/issue: this bug affects none version. process/fixed Process of bug severity/major Severity of bug type/bug Type: something is unexpected
Milestone

Comments

@bocai3030
Copy link

bocai3030 commented Jan 2, 2023

nebula server 3.3.0, java sdk 3.3.0

schema and data:

CREATE SPACE `test` (vid_type = FIXED_STRING(100)) 

CREATE EDGE `i2s` ();
CREATE EDGE `l` ();
CREATE EDGE `d` ();
CREATE TAG `S` (`name` string NOT NULL);
CREATE TAG `I` (`name` string NOT NULL  , `level` int NOT NULL  );
CREATE TAG `SIC` (`name` string NOT NULL);

insert vertex S(name) values "sid1":("s1");
insert vertex I(name, level) values "iid1":("s2",3);
insert vertex I(name, level) values "iid2":("s3",2);
insert vertex I(name, level) values "iid3":("s4",1);
insert vertex SIC(name) values "sicid1":("s5");
insert edge i2s() values "iid1" -> "sid1" : ();
insert edge l() values "iid2" -> "iid1" : ();
insert edge l() values "iid3" -> "iid2" : ();
insert edge d() values "sicid1" -> "iid3" : ();

query:
for (int i = 0; i < 10; i++) {
//...
use test;match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == "sid1" and id(v3) in ["sicid1"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level
//...
}

expected:
10 same query with same result with name "s2"
unexpected:
first query result, name is null.

@bocai3030 bocai3030 added the type/bug Type: something is unexpected label Jan 2, 2023
@github-actions github-actions bot added affects/none PR/issue: this bug affects none version. severity/none Severity of bug labels Jan 2, 2023
@yixinglu
Copy link
Contributor

yixinglu commented Jan 3, 2023

Did you always get the unexpected results after insertion? Or it exists only at the first time and do you check the result of the next 10 same queries?

I guess the inserted data might not be ready for the first query, so you got the NULL column.

@xtcyclist
Copy link
Contributor

xtcyclist commented Jan 3, 2023

(root@nebula) [test2]> insert edge l() values "iid2" -> "iid1" : ();
Execution succeeded (time spent 935/1028 us)

Tue, 03 Jan 2023 13:26:55 CST

(root@nebula) [test2]> insert edge l() values "iid3" -> "iid2" : ();
Execution succeeded (time spent 953/1041 us)

Tue, 03 Jan 2023 13:26:55 CST

(root@nebula) [test2]> insert edge d() values "sicid1" -> "iid3" : ();
Execution succeeded (time spent 1441/1657 us)

Tue, 03 Jan 2023 13:26:56 CST

(root@nebula) [test2]> match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == "sid1" and id(v3) in ["sicid1"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level
+--------+------+-------+
| id     | name | level |
+--------+------+-------+
| "iid1" | "s2" | 3     |
+--------+------+-------+
Got 1 rows (time spent 8545/8926 us)

Tue, 03 Jan 2023 13:27:03 CST

(root@nebula) [test2]> match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == "sid1" and id(v3) in ["sicid1"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level
+--------+------+-------+
| id     | name | level |
+--------+------+-------+
| "iid1" | "s2" | 3     |
+--------+------+-------+
Got 1 rows (time spent 8036/8327 us)

As shown above, I'm not able to reproduce this issue. The first query executed immediately after the last insert returns valid results. And, it repeats fine.

Please make sure all the inserts have been executed successfully, before issuing the match query in your codes.

@xtcyclist xtcyclist added need info Solution: need more information (ex. can't reproduce) type/TBD and removed type/bug Type: something is unexpected labels Jan 3, 2023
@xtcyclist
Copy link
Contributor

I update the label of this issue to type/TBD, since the nature of this issue is still to be determined. It may not be a bug.

@bocai3030
Copy link
Author

bocai3030 commented Jan 3, 2023

here are the whole code.
pom.xml:

    <dependency>
        <groupId>com.vesoft</groupId>
        <artifactId>client</artifactId>
        <version>3.3.0</version>
    </dependency>

java code:

@Configuration
@ConfigurationProperties(prefix = "nebula")
@EnableConfigurationProperties(NebulaGraphProperties.class)
@Data
public class NebulaGraphProperties {
    private String userName;
    private String password;
    private List<String> hostAddresses;
    private int minConnsSize;
    private int maxConnSize;
    private int timeout;
    private int idleTime;
    private String defaultSpace;
    private int intervalIdle;
}

@Configuration
@EnableConfigurationProperties({NebulaGraphProperties.class})
public class NebulaGraphConfig {
    @Autowired
    private NebulaGraphProperties nebulaGraphProperties;

    @Bean(destroyMethod = "close")
    public NebulaPool nebulaPool() throws UnknownHostException {
        final List<HostAddress> addressList = nebulaGraphProperties.getHostAddresses().stream().map(s -> {
            final String[] split = s.split(":");
            return new HostAddress(split[0], Integer.parseInt(split[1]));
        }).collect(Collectors.toList());

        NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig();
        nebulaPoolConfig.setMaxConnSize(nebulaGraphProperties.getMaxConnSize());
        nebulaPoolConfig.setMinConnSize(nebulaGraphProperties.getMinConnsSize());
        nebulaPoolConfig.setIdleTime(nebulaGraphProperties.getIdleTime());
        nebulaPoolConfig.setTimeout(nebulaGraphProperties.getTimeout());
        nebulaPoolConfig.setIntervalIdle(nebulaGraphProperties.getIntervalIdle());
        NebulaPool pool = new NebulaPool();
        pool.init(addressList, nebulaPoolConfig);
        return pool;
    }
}

@Component
public class NebulaSession {

    @Autowired
    NebulaPool nebulaPool;

    @Autowired
    NebulaGraphProperties nebulaGraphProperties;

    @Bean
    public Session session() throws Exception {
        return nebulaPool.getSession(nebulaGraphProperties.getUserName(),nebulaGraphProperties.getPassword(),true);
    }
}

public interface NebulaGraphService {

    ResultSet match(String spaceName, String ngql) throws IOErrorException;
}

@Service("nebulaGraphServiceImpl")
@Slf4j
public class NebulaGraphServiceImpl implements NebulaGraphService {

    @Autowired
    Session session;

    @Autowired
    NebulaGraphProperties nebulaGraphProperties;

    @Override
    public ResultSet match(String spaceName, String ngql) throws IOErrorException {
        if (StringUtils.isEmpty(spaceName)) {
            spaceName = nebulaGraphProperties.getDefaultSpace();
        }
        String exeNgql = String.format("use %s;" + ngql, spaceName);
        log.info("execute ngql: " + exeNgql);
        ResultSet resultSet = this.session.execute(exeNgql);
        checkResultSet(resultSet);

        return resultSet;
    }

    private void checkResultSet(ResultSet resultSet) {
        if (resultSet.isSucceeded()) {
            return;
        }
        throw new IllegalStateException("fail query nebula, code: " + resultSet.getErrorCode() + ", msg: " + resultSet.getErrorMessage());
    }

}


@RunWith(SpringRunner.class)
@SpringBootTest
public class XXXTest {

    @Autowired
    private NebulaGraphService nebulaGraphService;

    @Test
    public void t5() throws IOErrorException {
        for (int i = 0; i < 10; i++) {
            ResultSet resultSet = nebulaGraphService.match("", "match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == \"sid1\" and id(v3) in [\"sicid1\"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level");
            System.out.println(resultSet.getRows().get(0).values.get(1));
        }
    }

}

@bocai3030
Copy link
Author

bocai3030 commented Jan 3, 2023

@xtcyclist the way using nebula-console:

/usr/local/bin/nebula-console -u XX -p XX --address=graphd --port=9669
(root@nebula) [(none)]> use test;match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == "sid1" and id(v3) in ["sicid1"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level
+--------+----------+----------+
| id | name | level |
+--------+----------+----------+
| "iid1" | NULL | NULL |
+--------+----------+----------+
Got 1 rows (time spent 5.368ms/6.090147ms)

Tue, 03 Jan 2023 06:27:51 UTC

(root@nebula) [test]> use test;match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == "sid1" and id(v3) in ["sicid1"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level
+--------+------+-------+
| id | name | level |
+--------+------+-------+
| "iid1" | "s2" | 3 |
+--------+------+-------+
Got 1 rows (time spent 7.043ms/7.59679ms)

Tue, 03 Jan 2023 06:27:52 UTC

NOTE: must be the first query, and the "use test" and "match xxx" shall be sent in one query.

@xtcyclist
Copy link
Contributor

xtcyclist commented Jan 3, 2023

Welcome to Nebula Graph!

(root@nebula) [(none)]> use test2;match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == "sid1" and id(v3) in ["sicid1"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level
+--------+----------+----------+
| id     | name     | level    |
+--------+----------+----------+
| "iid1" | __NULL__ | __NULL__ |
+--------+----------+----------+
Got 1 rows (time spent 8643/8999 us)

Tue, 03 Jan 2023 14:30:10 CST

(root@nebula) [test2]> use test2;match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == "sid1" and id(v3) in ["sicid1"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level
+--------+------+-------+
| id     | name | level |
+--------+------+-------+
| "iid1" | "s2" | 3     |
+--------+------+-------+
Got 1 rows (time spent 8569/8835 us)

Tue, 03 Jan 2023 14:30:14 CST

Reproduced.

@xtcyclist xtcyclist added type/bug Type: something is unexpected and removed need info Solution: need more information (ex. can't reproduce) type/TBD labels Jan 3, 2023
@Sophie-Xie Sophie-Xie added this to the v3.4.0 milestone Jan 3, 2023
@xtcyclist xtcyclist modified the milestones: v3.4.0, v3.5.0 Jan 9, 2023
@xtcyclist xtcyclist added the severity/major Severity of bug label Jan 9, 2023
@github-actions github-actions bot removed the severity/none Severity of bug label Jan 9, 2023
@jievince
Copy link
Contributor

This bug has been fixed by #5390.


Welcome to Nebula Graph!

(root@nebula) [(none)]> use test;match (v:S)<-[]-(v1:I)<-[e3*3]-(v3:SIC) where id(v) == "sid1" and id(v3) in ["sicid1"] return id(v1) AS id, v1.I.name AS name,v1.I.level AS level 
+--------+------+-------+
| id     | name | level |
+--------+------+-------+
| "iid1" | "s2" | 3     |
+--------+------+-------+
Got 1 rows (time spent 12.61ms/13.169082ms)

Mon, 20 Mar 2023 17:02:03 CST

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects/none PR/issue: this bug affects none version. process/fixed Process of bug severity/major Severity of bug type/bug Type: something is unexpected
Projects
None yet
Development

No branches or pull requests

5 participants