Client.query error on non-single server cluster

Please help me fix the error.

I’m trying to do a simple left join two sets on a java client, And I get the result I expect when I query a single node cluster. But when I run the same application with 2(or more) nodes cluster I get server error… (Error Code 1: Server error)

and the server log looks like this…

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::844) scan job received

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::895) scan_option 0x0 0x64

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::986) scan option: Fail if cluster change False

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::987) scan option: Background Job False

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::988) scan option: priority is 0 n_threads 3 job_type 1

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::989) scan option: scan_pct is 100

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::1419) tid 1292795995097594: scan send response error returned -1 errno 32 fd 85

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::386) SCAN JOB DONE [id =1292795995097594: ns= test set=Student_Set scanned=3 expired=0 set_diff=1 elapsed=17 (ms)]

Jun 19 2015 05:51:44 GMT: INFO (scan): (thr_tscan.c::1464) tid 1292795995097594: no more fh. Probably client closed up connection

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4744) system memory: free 16008524kb ( 98 percent free )

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4752) migrates in progress ( 0 , 0 ) ::: ClusterSize 2 ::: objects 10 ::: sub_objects 0

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4760) rec refs 10 ::: rec locks 0 ::: trees 0 ::: wr reqs 0 ::: mig tx 0 ::: mig rx 0

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4766) replica errs :: null 0 non-null 0 ::: sync copy errs :: node 0 :: master 0

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4776) trans_in_progress: wr 0 prox 0 wait 0 ::: q 0 ::: bq 0 ::: iq 0 ::: dq 0 : fds - proto (3, 12, 9) : hb (2, 2, 0) : fab (20, 20, 0)

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4778) heartbeat_received: self 0 : foreign 661

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4779) heartbeat_stats: bt 0 bf 509 nt 0 ni 0 nn 0 nnir 0 nal 0 sf1 0 sf2 0 sf3 0 sf4 0 sf5 0 sf6 0 mrf 0 eh 0 efd 0 efa 0 um 0 mcf 0 rc 0

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4792) tree_counts: nsup 0 scan 0 batch 0 dup 0 wprocess 0 migrx 0 migtx 0 ssdr 0 ssdw 0 rw 0

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4808) namespace test: disk inuse: 0 memory inuse: 1181 (bytes) sindex memory inuse: 56118 (bytes) avail pct 100

Jun 19 2015 05:51:45 GMT: INFO (info): (thr_info.c::4853) partitions: actual 2077 sync 2019 desync 0 zombie 0 wait 0 absent 0

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::137) histogram dump: reads (0 total) msec

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::137) histogram dump: writes_master (10 total) msec

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::163) (00: 0000000010)

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::137) histogram dump: proxy (0 total) msec

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::137) histogram dump: writes_reply (10 total) msec

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::163) (00: 0000000010)

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::137) histogram dump: udf (0 total) msec

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::137) histogram dump: query (0 total) msec

Jun 19 2015 05:51:45 GMT: INFO (info): (hist.c::137) histogram dump: query_rec_count (0 total) count

And the code look like this…

public void join() {

    Key key;

    Record record1;

    Record record2;

    Record[] result;



    /*

     * Prepare a statement

     */

    Statement stmt1 = new Statement();



    stmt1.setNamespace(this.namespace);

    stmt1.setSetName(STUDENT_SET);

    stmt1.setBinNames(STUDENT_NAME, "Advisor_ID");



    /*

     * exxecute query

     */

    try {

        RecordSet rs1 = this.client.query(null, stmt1);

        /*

         * process results as they arrive from the cluster

         */

        while (rs1.next()){

            record1 = rs1.getRecord();

            key = new Key(this.namespace, ADVISOR_SET, (String)record1.bins.get("Advisor_ID"));

            record2 = this.client.get(null, key);

            System.out.println(record1);

            System.out.println(record2);

            key=null;

        }

    } catch (AerospikeException e) {

        System.out.println(e.getMessage());

    }

}

Some comments/questions:

  1. rs1.close() must be called after the query completes, preferably in a try/finally or using block.

  2. The server logs indicate the client application exited prematurely. Are you getting an exception? What is the client output?

  3. What version of the client and server are you using?

Hi~ Thanks for the reply

  1. Thank you, I think I missed out rs1.close() editing my code many times…

  2. Like I wrote in the original question, I get “Error Code 1: Server error”

  3. Currently I’m using aerospike-server-community-3.5.12-el6 and java client 3.1.2

Hope this helps~

I have created a complete join example that works fine. I recommend following this template:

package com.aerospike.examples;

import com.aerospike.client.AerospikeClient;
import com.aerospike.client.Bin;
import com.aerospike.client.Key;
import com.aerospike.client.Record;
import com.aerospike.client.query.RecordSet;
import com.aerospike.client.query.Statement;

public class QueryStudents extends Example {

	private final String STUDENT_SET = "Student_Set";
	private final String STUDENT_NAME = "Student_Name";
	private final String ADVISOR_SET = "Advisor_Set";
	private final String ADVISOR_ID = "Advisor_ID";
	private final String ADVISOR_NAME = "Advisor_Name";
	
	public QueryStudents(Console console) {
		super(console);
	}

	@Override
	public void runExample(AerospikeClient client, Parameters params) throws Exception {
		client.put(null, new Key(params.namespace, ADVISOR_SET, "Advisor1"), new Bin(ADVISOR_ID, "Advisor1"), new Bin(ADVISOR_NAME, "Sally"));
		client.put(null, new Key(params.namespace, ADVISOR_SET, "Advisor7"), new Bin(ADVISOR_ID, "Advisor7"), new Bin(ADVISOR_NAME, "John"));

		client.put(null, new Key(params.namespace, STUDENT_SET, "Bill"), new Bin(STUDENT_NAME, "Bill"), new Bin(ADVISOR_ID, "Advisor1"));
		client.put(null, new Key(params.namespace, STUDENT_SET, "Tom"), new Bin(STUDENT_NAME, "Tom"), new Bin(ADVISOR_ID, "Advisor1"));
		client.put(null, new Key(params.namespace, STUDENT_SET, "Charlie"), new Bin(STUDENT_NAME, "Charlie"), new Bin(ADVISOR_ID, "Advisor7"));
		
		Statement stmt = new Statement();
		stmt.setNamespace(params.namespace);
		stmt.setSetName(STUDENT_SET);
		stmt.setBinNames(STUDENT_NAME, ADVISOR_ID);
		
		RecordSet rs = client.query(null, stmt);
		
		try {
			while (rs.next()) {
				Record record1 = rs.getRecord();
				System.out.println("Student: " + record1);
				
				String id = record1.getString(ADVISOR_ID);
				
				Record record2 = client.get(null, new Key(params.namespace, ADVISOR_SET, id));				
				System.out.println("Advisor: " + record2);
			}
		}
		finally {
			rs.close();
		}
	}
}