Tag Archives: set

[Solved] seata Error: io.seata.rm.datasource.exec.LockConflictException: get global lock fail, xid:xxx, lockKeys:xxx

io.seata.rm.datasource.exec.LockConflictException: get global lock fail, xid:xxx, lockKeys:xxx
the error here shows that the global lock acquisition failed
in fact, it may not be the problem of global lock. Here, you can directly check the detailed error in the log file of Seata server

determine the error information

the error of Seata here is because the table field of Seata database is smaller by default and longer_ the table_name will be OK.

Docker builds the pit that Seata stepped on. can not connect to services-server

An error is reported when the system starts: can not connect to services server.
Always connect to the intranet IP by default, but my configuration file specifies the extranet.

2020-07-29 14:53:39.075 ERROR 20356 --- [           main] i.s.c.r.netty.NettyClientChannelManager  : 0101 can not connect to 172.19.231.5:8091 cause:can not register RM,err:can not connect to services-server.
 
io.seata.common.exception.FrameworkException: can not register RM,err:can not connect to services-server.
	at io.seata.core.rpc.netty.NettyClientChannelManager.doConnect(NettyClientChannelManager.java:210) ~[seata-all-1.3.0.jar:1.3.0]
	at io.seata.core.rpc.netty.NettyClientChannelManager.acquireChannel(NettyClientChannelManager.java:103) ~[seata-all-1.3.0.jar:1.3.0]
	at io.seata.core.rpc.netty.NettyClientChannelManager.reconnect(NettyClientChannelManager.java:175) ~[seata-all-1.3.0.jar:1.3.0]

The configuration address of the mount directory is not easy to use, or it can’t be connected, and the error has been reported all the time

docker run -id --name seata-server -p 8091:8091 \
-v /java/seata/resources/file.conf:/seata-server/resources/file.conf \
-v /java/seata/resources/registry.conf:/seata-server/resources/registry.conf \
-v /java/seata/logs:/root/logs \
seataio/seata-server:1.3.0 /bin/bash

Finally, IP and final version should be specified at runtime to solve the problem

 docker run -id --name seata-server -p 8091:8091 \
> -e SEATA_IP=192.168.23.129 \
> -e SEATA_PORT=8091 \
> -v /java/seata/resources/file.conf:/seata-server/resources/file.conf \
> -v /java/seata/resources/registry.conf:/seata-server/resources/registry.conf \
> -v /java/seata/logs:/root/logs \
> seataio/seata-server:1.3.0

Compare whether two sets are the same in Java

in Java API, it seems that there is no way to compare the contents of two sets, so we can only write one by ourselves to realize it. In fact, it is relatively simple to compare the number of records to see whether they are the same, and then see whether the contents are consistent. The test method is as follows:

public static boolean equals(Set<?> set1, Set<?> set2){
        if(set1 == null || set2 ==null){//null就直接不比了
            return false;
        }
        if(set1.size()!=set2.size()){//大小不同也不用比了
            return false;
        }
        return set1.containsAll(set2);//最后比containsAll
    }

unit test:

import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
public class TestSetUtils {
    @Test
    public void test1() {
        Set<String> test1 = new HashSet<>();
        test1.add("a");
        test1.add("b");
        Set<String> test2 = new HashSet<>();
        test2.add("b");
        test2.add("c");
        assertThat(SetUtils.equals(test1, test2), is(false));
    }
    @Test
    public void test2() {
        Set<String> test1 = new HashSet<>();
        test1.add("a");
        test1.add("b");
        Set<String> test2 = new HashSet<>();
        test2.add("a");
        test2.add("b");
        test2.add("c");
        assertThat(SetUtils.equals(test1, test2), is(false));
    }
    @Test
    public void test3() {
        Set<String> test1 = new HashSet<>();
        test1.add("a");
        test1.add("b");
        test1.add("c");
        Set<String> test2 = new HashSet<>();
        test2.add("a");
        test2.add("b");
        assertThat(SetUtils.equals(test1, test2), is(false));
    }
    //set ignore sequence
    @Test
    public void test4() {
        Set<String> test1 = new HashSet<>();
        test1.add("a");
        test1.add("b");
        Set<String> test2 = new HashSet<>();
        test2.add("b");
        test2.add("a");
        assertThat(SetUtils.equals(test1, test2), is(true));
    }
    @Test
    public void test5() {
        Set<String> test1 = new HashSet<>();
        test1.add("a");
        Set<String> test2 = new HashSet<>();
        test2.add("a");
        assertThat(SetUtils.equals(test1, test2), is(true));
    }
}

reproduced from: http://ju.outofmemory.cn/entry/288737