You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by vinshar <vi...@gmail.com> on 2016/01/12 07:29:55 UTC

SQL Query returns no value if different values put twice with same key

Hi,

Below is a test code for a behavior i noticed. Below code returns nothing
for SQL query if i add a entry twice on cache. I tested this with 1.4
version. 

problem 1:- For below code, SQL query returns no result where as text query
does. If i comment 3rd put comment then both SQL and text queries return
result. Text query returns 1 value both times.

Problem 2:- If i enable client mode i see ClassNotFound exception for Person
class in server node logs. This appears even if peerClassLoading is true on
both client and server.

problem 3:- If i upgrade POM to use version 1.5.0.final then i get following
error even though client node is false and there is no other node running on
my local machine.

/Caused by: class org.apache.ignite.spi.IgniteSpiException: Local node and
remote node have different version numbers (node will not join, Ignite does
not support rolling updates, so versions must be exactly the same)/

	public static void main(String[] args) throws Exception {
		class Person implements Serializable {
			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@QuerySqlField(index = true)
			private int id;

			@QueryTextField
			private String personName;

			public Person(int personId, String personName) {
				super();
				this.id = personId;
				this.personName = personName;
			}

			public int getId() {
				return id;
			}

			public void setId(int personId) {
				this.id = personId;
			}

			public String getPersonName() {
				return personName;
			}

			public void setPersonName(String personName) {
				this.personName = personName;
			}

		}
		
		Ignite ignite = Ignition.start(new
IgniteConfiguration().setClientMode(false).setPeerClassLoadingEnabled(true));

		CacheConfiguration<Integer, Person> config = new CacheConfiguration<>();
		config.setName("PROBLEM");
		config.setIndexedTypes(Integer.class, Person.class);
		IgniteCache cache = ignite.createCache(config);
		
		cache.put(1, new Person(1,"test1"));
		cache.put(2, new Person(2,"test2"));
		cache.put(2, new Person(3,"test2"));

		SqlQuery<Integer, Person> sql = new SqlQuery<>(Person.class, "from Person
where id = 2");
		TextQuery<Integer, Person> text = new TextQuery<>(Person.class, "test2");
	
System.out.println("##################################################################");
		System.out.println(cache.get(2));
		System.out.println(cache.query(sql).getAll());
		System.out.println(cache.query(text).getAll());
	
System.out.println("##################################################################3");
	
	}







--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/SQL-Query-returns-no-value-if-different-values-put-twice-with-same-key-tp2509.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: SQL Query returns no value if different values put twice with same key

Posted by vinshar <vi...@gmail.com>.
you are right. with 1.4 if i put class on ignite classpath it works and 1.5
works without class.
Thanks. 



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/SQL-Query-returns-no-value-if-different-values-put-twice-with-same-key-tp2509p2544.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: SQL Query returns no value if different values put twice with same key

Posted by Denis Magda <dm...@gridgain.com>.
Hi Vinay,

To overcome the exception you have to add the class to server's node 
classpath as well.
If you don't want to have classes in server nodes classpath you can 
start using Ignite 1.5.0 release that has binary objects[1] in its 
features list.

[1] https://apacheignite.readme.io/docs/binary-marshaller

--
Denis

On 1/12/2016 4:37 PM, vinay sharma wrote:
>
> Hi Val,
>
> You are right. I totally missed the point that i changed id of 2nd 
> object.
>
> There was no system in my network and visor also showed nothing. I 
> will restart system and try again.
>
> How about class not found exception. Am i doing something wrong in 
> this code which should cause this exception on server node?
>
> Regards,
> Vinay
>


Re: SQL Query returns no value if different values put twice with same key

Posted by vinay sharma <vi...@gmail.com>.
Hi Val,

You are right. I totally missed the point that i changed id of 2nd object.

There was no system in my network and visor also showed nothing. I will
restart system and try again.

How about class not found exception. Am i doing something wrong in this
code which should cause this exception on server node?

Regards,
Vinay

Re: SQL Query returns no value if different values put twice with same key

Posted by Valentin Kulichenko <va...@gmail.com>.
Vinay,

The last put operation updates Person with key '2' and changes its 'id'
field value to '3'. As a result, there are no persons with id=2 and SQL
query, which selects by this condition, returns empty result. Test query is
based on 'personName' field which is not changed, therefore result of the
query does not change as well.

As for error in 1.5.0, you definitely still have 1.4 node(s) running
somewhere. Please double-check Java processes of your computer and other
computers in the same network if there are any.

-Val

On Mon, Jan 11, 2016 at 10:29 PM, vinshar <vi...@gmail.com> wrote:

> Hi,
>
> Below is a test code for a behavior i noticed. Below code returns nothing
> for SQL query if i add a entry twice on cache. I tested this with 1.4
> version.
>
> problem 1:- For below code, SQL query returns no result where as text query
> does. If i comment 3rd put comment then both SQL and text queries return
> result. Text query returns 1 value both times.
>
> Problem 2:- If i enable client mode i see ClassNotFound exception for
> Person
> class in server node logs. This appears even if peerClassLoading is true on
> both client and server.
>
> problem 3:- If i upgrade POM to use version 1.5.0.final then i get
> following
> error even though client node is false and there is no other node running
> on
> my local machine.
>
> /Caused by: class org.apache.ignite.spi.IgniteSpiException: Local node and
> remote node have different version numbers (node will not join, Ignite does
> not support rolling updates, so versions must be exactly the same)/
>
>         public static void main(String[] args) throws Exception {
>                 class Person implements Serializable {
>                         /**
>                          *
>                          */
>                         private static final long serialVersionUID = 1L;
>
>                         @QuerySqlField(index = true)
>                         private int id;
>
>                         @QueryTextField
>                         private String personName;
>
>                         public Person(int personId, String personName) {
>                                 super();
>                                 this.id = personId;
>                                 this.personName = personName;
>                         }
>
>                         public int getId() {
>                                 return id;
>                         }
>
>                         public void setId(int personId) {
>                                 this.id = personId;
>                         }
>
>                         public String getPersonName() {
>                                 return personName;
>                         }
>
>                         public void setPersonName(String personName) {
>                                 this.personName = personName;
>                         }
>
>                 }
>
>                 Ignite ignite = Ignition.start(new
>
> IgniteConfiguration().setClientMode(false).setPeerClassLoadingEnabled(true));
>
>                 CacheConfiguration<Integer, Person> config = new
> CacheConfiguration<>();
>                 config.setName("PROBLEM");
>                 config.setIndexedTypes(Integer.class, Person.class);
>                 IgniteCache cache = ignite.createCache(config);
>
>                 cache.put(1, new Person(1,"test1"));
>                 cache.put(2, new Person(2,"test2"));
>                 cache.put(2, new Person(3,"test2"));
>
>                 SqlQuery<Integer, Person> sql = new
> SqlQuery<>(Person.class, "from Person
> where id = 2");
>                 TextQuery<Integer, Person> text = new
> TextQuery<>(Person.class, "test2");
>
>
> System.out.println("##################################################################");
>                 System.out.println(cache.get(2));
>                 System.out.println(cache.query(sql).getAll());
>                 System.out.println(cache.query(text).getAll());
>
>
> System.out.println("##################################################################3");
>
>         }
>
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/SQL-Query-returns-no-value-if-different-values-put-twice-with-same-key-tp2509.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: SQL Query returns no value if different values put twice with same key

Posted by vkulichenko <va...@gmail.com>.
Vinay,

Yes, it starts an embedded daemon node that provides connectivity with the
cluster. It joins the topology on discovery protocol level, but never
participates in any cluster activities like running computations or storing
the data. It's also not visible in topology snapshots.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/SQL-Query-returns-no-value-if-different-values-put-twice-with-same-key-tp2509p2591.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: SQL Query returns no value if different values put twice with same key

Posted by vinshar <vi...@gmail.com>.
Exception mentioned in problem 3 was because of visor. all nodes were down
but visor console which i started using the same config as cache nodes was
still up. 
I forgot that to connect to ignite, process should have its own node started
and so might have done by visor as well.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/SQL-Query-returns-no-value-if-different-values-put-twice-with-same-key-tp2509p2585.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.