You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by zshamrock <al...@gmail.com> on 2016/06/15 10:49:10 UTC

Strange collocated distributed set behavior

Here is the sample code:

package experiments.ignite;

import java.util.Arrays;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSet;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.CollectionConfiguration;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;

public class DistributedSetDemo {
    public static void main(final String[] args) {
        final Ignite ignite = Ignition.start();
        final CollectionConfiguration collectionConfiguration = new
CollectionConfiguration();
        collectionConfiguration.setCollocated(true); // 1
//        collectionConfiguration.setBackups(1); // 2
        System.out.printf("Started node %s\n",
ignite.cluster().localNode().id());
        IgniteSet<Long> numbers = ignite.set("numbers", null);
        if (numbers == null) {
            numbers = ignite.set("numbers", collectionConfiguration);
        }
        System.out.printf("[local] Size of the numbers distributed set is
%d, and items are %s\n",
                numbers.size(),
                Arrays.toString(numbers.toArray(new Long[numbers.size()])));
        System.out.printf("[local] Is collocated? %b\n",
numbers.collocated());
        System.out.printf("[local] numbers contains 42? %b\n",
numbers.contains(42L));
        numbers.affinityRun(new IgniteRunnable() {
            @IgniteInstanceResource
            private Ignite ignite;

            @LoggerResource
            private IgniteLogger logger;

            @Override
            public void run() {
                System.out.println(String.format("[affinity] Running on %s
node", ignite.cluster().localNode().id()));
                final IgniteSet<Long> affinityNumbers =
ignite.set("numbers", null);
                System.out.printf("[affinity] Size of the numbers
distributed set is %d, and items are %s\n",
                        affinityNumbers.size(),
                        Arrays.toString(affinityNumbers.toArray(new
Long[affinityNumbers.size()])));
                System.out.printf("[affinity] Is collocated? %b\n",
affinityNumbers.collocated());
                System.out.printf("[affinity] numbers contains 42? %b\n",
affinityNumbers.contains(42L));
            }
        });
        numbers.add(42L);
    }
}


or here https://gist.github.com/zshamrock/ac5e907bf1b091ad05570f77ae1ba69f.

Below are different scenarios with the actual and expected behavior.

Scenario #1

 - Run first instance 
Started node 54e59a6c-dc40-4038-b225-b7f8a0a343cf
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? false
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 0, and items are []
[affinity] Is collocated? true
[affinity] numbers contains 42? false

- Run second instance
(from first instance console)
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 1, and items are [42]
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from second instance console)
Started node 83429a51-0e6f-48d3-a991-b0fbbe6ac58e
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? true

- Run third instance
(from first instance console)
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 1, and items are [42]
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from third instance console)
Started node e844d3fc-e9c2-4bb3-8dab-efe44281c96f
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? true

- Stop first instance

- Run fourth instance
(from third instance console)
[affinity] Running on e844d3fc-e9c2-4bb3-8dab-efe44281c96f node
[affinity] Size of the numbers distributed set is 0, and items are []
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from fourth instance console)
Started node b3aff359-80eb-4a26-aa3a-f8ba16d248ee
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? true

*Actual behavior*
See above

*Expected behavior*
1. As there is no backup configured, I have not expected Set ownership to be
taken by 3rd instance.

2. Even, if 3rd instance took the ownership of the Set, the output from the
affinity run is strange, as comparing to the original affinity output from
the 1st instance (which reports the correct size, and toArray()), 3rd
instance only reports "contains", but empty for size() and toArray(). Which
is weird.

3. I still have expected "local" access to the distributed set would return
proper size and toArray(). Which it doesn't. Also strange to see although
"contains" reports true for all the cases.

Scenario #2 (with backups enabled)

Same behavior as for the Scenario #1

Scenario #3

(do not know how to reproduce it all the time, but saw it multiple times)

- Run first instance
Started node 54e59a6c-dc40-4038-b225-b7f8a0a343cf
[local] Size of the numbers distributed set is 0, and items are []
[local] Is collocated? true
[local] numbers contains 42? false
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 0, and items are []
[affinity] Is collocated? true
[affinity] numbers contains 42? false

- Run second instance
(from first instance console)
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 1, and items are [42]
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from second instance console)
Started node 83429a51-0e6f-48d3-a991-b0fbbe6ac58e
*[local] Size of the numbers distributed set is 1, and items are [42]*!!!
[local] Is collocated? true
[local] numbers contains 42? true

- Run third instance 
(from first instance console)
[affinity] Running on 54e59a6c-dc40-4038-b225-b7f8a0a343cf node
[affinity] Size of the numbers distributed set is 1, and items are [42]
[affinity] Is collocated? true
[affinity] numbers contains 42? true

(from third instance console)
Started node e844d3fc-e9c2-4bb3-8dab-efe44281c96f
*[local] Size of the numbers distributed set is 0, and items are []*!!!
[local] Is collocated? true
[local] numbers contains 42? true

*Actual behavior*
See above

*Expected behavior*
Strange to see 2nd instance has reported the correct size and toArray()
(again it is not always happening), while the 3rd instance goes back to
report nothing (0 for the size, and empty toArray()).



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Strange-collocated-distributed-set-behavior-tp5643.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Strange collocated distributed set behavior

Posted by zshamrock <al...@gmail.com>.
Thank you, Andrey. I will be monitoring the progress of this issue.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Strange-collocated-distributed-set-behavior-tp5643p5963.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Strange collocated distributed set behavior

Posted by AndreyVel <an...@gmail.com>.
It is magic, now DistributedSetDemo for new node shows size() == 0.

Since there is no backup configured for the set it’s a normal situation when
the set is empty 
after all the nodes that held its data had left the topology. Please note,
that the set as a data structure 
is not removed in such a case, to remove the set completely set.close()
method has to be used.
However I could reproduce the issue with wrong cache size when the second
node is started. 

Here is the ticket: https://issues.apache.org/jira/browse/IGNITE-3373
Hope that someone from the community will fix it soon.





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Strange-collocated-distributed-set-behavior-tp5643p5925.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Strange collocated distributed set behavior

Posted by zshamrock <al...@gmail.com>.
Hi, Andrey. Any progress with this? Was you able to reproduce this one on
your machine?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Strange-collocated-distributed-set-behavior-tp5643p5884.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Strange collocated distributed set behavior

Posted by Andrey Velichko <an...@gmail.com>.
Hello zshamroc,

I will try reproduce you scenarios.
maybe you need add sleep() at the end of program and no stop program in 
debugger?

What topology messages do you get in fourth instance?
How many memory has you server and what initial heap size?


17.06.2016 12:43, zshamrock \u043f\u0438\u0448\u0435\u0442:
> Any comment from Ignite/DataGrid? As it looks like a bug to me.
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Strange-collocated-distributed-set-behavior-tp5643p5707.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Strange collocated distributed set behavior

Posted by zshamrock <al...@gmail.com>.
Any comment from Ignite/DataGrid? As it looks like a bug to me.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Strange-collocated-distributed-set-behavior-tp5643p5707.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Strange collocated distributed set behavior

Posted by AndreyVel <an...@gmail.com>.
Hello zshamrock,

I cannot reproduce you issue Scenario#1 on Ignite 1.6.0.
It is strange why instance 2-3-4 prints:
	[local] Size of the numbers distributed set is 0, and items are [] 

Should be
	[local] Size of the numbers distributed set is 1, and items are [42]


To be honest I have used local cluster configuration

        IgniteConfiguration cfg = new IgniteConfiguration();
        cfg.setPeerClassLoadingEnabled(true);
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));

        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
        discoSpi.setIpFinder(ipFinder);
        cfg.setDiscoverySpi(discoSpi);
        final Ignite ignite = Ignition.start(cfg);

Please add logging collection creation

        IgniteSet<Long> numbers = ignite.set("numbers", null);
        if (numbers == null) {
            System.out.println("[local] creating collection [numbers]");
            numbers = ignite.set("numbers", collectionConfiguration);
        }

and at the end of code put

        numbers.add(42L);
        System.out.printf("Waiting 6000 sec...");
        Thread.sleep(1000 * 6000);



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Strange-collocated-distributed-set-behavior-tp5643p5909.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.