Android, Ektorp with CBLite-1.0.0.-beta2 : Failed to rebuild view xxxx : 500

284 views
Skip to first unread message

bpolan

unread,
Feb 13, 2014, 1:18:06 PM2/13/14
to mobile-c...@googlegroups.com
Hi,

it seems there is some kind of problem with using ektorp on beta2 version of cbl for android. The application that I work on was already tested and working with older version of CBL returning data.

When I execute this : 
      final List<CouchDbTable> result = db.queryView(createQuery("by_company_and_name").key(ComplexKey.of(company, name)), CouchDbTable.class);

result is null and in log pops this message :


02-13 19:09:08.666: V/Database(2792): Re-indexing view CouchDbTable/by_company_and_name ...
02-13 19:09:08.666: I/CBLSQL(2792): pool-1-thread-1 Begin transaction (level 1)
02-13 19:09:08.666: D/CBLSQL(2792): pool-1-thread-1 start running query: SELECT lastSequence FROM views WHERE name=?
02-13 19:09:08.666: D/CBLSQL(2792): pool-1-thread-1 finish running query: SELECT lastSequence FROM views WHERE name=?
02-13 19:09:08.666: D/Database(2792): lastSequence (2061) == dbMaxSequence (2061), nothing to do
02-13 19:09:08.666: W/Database(2792): Failed to rebuild view CouchDbTable/by_company_and_name: 500
02-13 19:09:08.666: I/CBLSQL(2792): pool-1-thread-1 CANCEL transaction (level 1)
02-13 19:09:08.666: D/CBLSQL(2792): pool-1-thread-1 start running query: SELECT lastSequence FROM views WHERE name=?
02-13 19:09:08.666: D/CBLSQL(2792): pool-1-thread-1 finish running query: SELECT lastSequence FROM views WHERE name=?
02-13 19:09:08.746: V/Database(2792): Query CouchDbTable/by_company_and_name: SELECT key, value, docid, revs.sequence FROM maps, revs, docs WHERE maps.view_id=? AND key in (?) AND revs.sequence = maps.sequence AND docs.doc_id = revs.doc_id ORDER BY key LIMIT ? OFFSET ?

What is 500 error and why view fails to rebuild?

Thanks!

Matt Quinn

unread,
Feb 13, 2014, 2:30:48 PM2/13/14
to mobile-c...@googlegroups.com


bpolan <bojan....@gmail.com> wrote:
>02-13 19:09:08.666: D/Database(2792): lastSequence (2061) ==
>dbMaxSequence
>(2061), nothing to do
>*02-13 19:09:08.666: W/Database(2792): Failed to rebuild view
>CouchDbTable/by_company_and_name: 500*
>
>What is 500 error and why view fails to rebuild?

This is a misleading error message. Nothing's wrong -- the view isn't rebuilding because it doesn't have to (see log message one line earlier).

This has already been fixed, but I guess it didn't make it into beta 2.
https://github.com/couchbase/couchbase-lite-java-core/pull/28

Traun Leyden

unread,
Feb 13, 2014, 4:49:09 PM2/13/14
to mobile-c...@googlegroups.com

I just checked the commit logs and it looks like that change didn't make it into beta2.



--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/2ac34115-b102-4243-a063-be8b37db5987%40email.android.com.

bpolan

unread,
Feb 13, 2014, 5:00:28 PM2/13/14
to mobile-c...@googlegroups.com
Thanks,

then the problem I have is not there. 

public class EmployeeDaoImpl extends CouchDbRepositorySupport<Employee> implements EmployeeDao {

private CouchDbConnector dba;

    public EmployeeDaoImpl(CouchDbConnector db) {
        super(Employee.class, db);
        this.dba = db;
    }

When I use Ektorps CouchDbRepositorySupport class queries return nothing:

        db.queryView(createQuery(ViewsEmployee.BY_TAG_ID).key(tag), CouchDbTable.class);

When I bypass CouchDbRepositorySupport i get results : 

        ViewQuery viewQuery = new ViewQuery().designDocId("_design/" + ViewsEmployee.DESIGN_DOC).viewName(ViewsEmployee.BY_TAG_ID).key(tag);  
        ViewResult result = dba.queryView(viewQuery);  

When there is no results no error appears just result is null. So the view is found.
Don't know what would be the problem ?

bpolan

unread,
Feb 13, 2014, 5:02:35 PM2/13/14
to mobile-c...@googlegroups.com
   db.queryView(createQuery(ViewsEmployee.BY_TAG_ID).key(tag), CouchDbTable.class);     is Employee.class   typo in last post

Traun Leyden

unread,
Feb 14, 2014, 7:54:16 PM2/14/14
to mobile-c...@googlegroups.com

I just updated the couchbase-lite-android-ektorp project so that the tests are passing (was just some API renames that broke tests compilation)

Can you check out the tests here:


and try to see what you are doing differently than the tests?

bpolan

unread,
Feb 17, 2014, 2:28:37 AM2/17/14
to mobile-c...@googlegroups.com
Hi Traun , 

I tried the test cases and this works with no problem. This in the tests is the second way I tried where you don't use the CouchDbRepositorySupport<?> which gives ability to implement CRUD "out of box" http://ektorp.org/javadoc/ektorp/1.2.2/org/ektorp/support/CouchDbRepositorySupport.html .  

If you try to query views via mentioned class it does not work ok, while create, update, delete work ok.
I am using now approach like in the tests for querying and for create, read, update, the mentioned class support.

Thanks for help!
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchbase+unsubscribe@googlegroups.com.

Traun Leyden

unread,
Feb 17, 2014, 12:37:25 PM2/17/14
to mobile-c...@googlegroups.com
I'm a little confused, can you give a concrete example of a query that doesn't work? 




Bojan Polanec

unread,
Feb 18, 2014, 2:25:27 AM2/18/14
to mobile-c...@googlegroups.com
Any of the query methods in the ektorp class :

i.e. 
protected  List<T> queryView(String viewName, int key) 
          Allows subclasses to query views with simple String value keys and load the result as the repository's handled type.

Assuming we have all the correct views. We instance this class below with db connector and execute the method :


import org.ektorp.support.CouchDbRepositorySupport;

public class EmployeeDaoImpl extends CouchDbRepositorySupport<Employee> implements Employee {

   public EmployeeDaoImpl (final CouchDbConnector db) {
        super(Employee.class, db);
    }

    @Override
    public Table findByCompanyAndName(final String company, final String name) {
        final List<Employee> result = db.queryView(createQuery("by_company_and_name").key(ComplexKey.of(company,
                name)), Employee.class);
        if (result.size() == 0) {
            return null;
        }
        return result.get(0);
    }


}

result is an empty collection when querying like that even when data exists. When querying like you did, NOT using CouchDbRepositorySupport like in your tests it works with no problem.


Hope is clearer now.







--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/GbFXIY_XMVo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/CACSSHCGvD-Bde%3DSmY5UBNpKM2vUw%2B7k-mt9rQXBx78vHXZjU3A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages