Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live select in v3 provides the wrong RID. #7828

Closed
pvalsecc opened this issue Oct 17, 2017 · 6 comments
Closed

Live select in v3 provides the wrong RID. #7828

pvalsecc opened this issue Oct 17, 2017 · 6 comments
Assignees

Comments

@pvalsecc
Copy link

OrientDB Version: ca8d27f

Java Version: 1.8.0_131

OS: Ubuntu 17.04

Expected behavior

I do on a freshly created DB:

CREATE CLASS Test EXTENDS V
CREATE PROPERTY Test.x STRING
LIVE SELECT FROM Test

I expect to receive notifications with the correct RIDs when stuff is added to the Test table with INSERT INTO Test (x) VALUES ('X').

Actual behavior

The INSERT command returns a correct RID (#25:0), but the notification I get from my live subscription has RID=#25:-2. I guess you send the notification before assigning the cluster position.

Steps to reproduce

Described in the "Expected behavior" section.

@pvalsecc pvalsecc changed the title Live select in 3.0 provides the wrong RID. Live select in v3 provides the wrong RID. Oct 17, 2017
@luigidellaquila luigidellaquila self-assigned this Oct 20, 2017
@luigidellaquila
Copy link
Member

hi @pvalsecc

Which API are you using? Could you please post a code snippet to reproduce the problem?
I added a couple of test cases, but they seem to work fine...

Thanks

Luigi

@pvalsecc
Copy link
Author

I'm developing an Erlang driver. But here is the java program I've used to reverse engineer the stuff that was lacking in the protocol documentation:

package ch.thus.erlping;

import com.orientechnologies.common.exception.OException;
import com.orientechnologies.orient.client.remote.OServerAdmin;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.db.record.ORecordOperation;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.orientechnologies.orient.core.sql.query.OLiveQuery;
import com.orientechnologies.orient.core.sql.query.OLiveResultListener;

import java.io.IOException;
import java.util.List;

public class Live {

    public static final String DB_URL = "remote:localhost/test";

    public static void main(String[] args) throws IOException, InterruptedException {
        OServerAdmin admin = new OServerAdmin(DB_URL)
                .connect("root", "root")
                .createDatabase("graph", "plocal");
        try {
            ODatabaseDocumentTx db = new ODatabaseDocumentTx(DB_URL).open("root", "root");
            try {
                System.out.println("Create DB");
                db.command(new OCommandSQL("create class Test")).execute();

                System.out.println("LIVE");
                List<ODocument> result = db.query(new OLiveQuery<ODocument>("live select from Test", new OLiveResultListener() {
                    public void onLiveResult(int iLiveToken, ORecordOperation iOp) throws OException {
                        System.out.println("Got result " + iOp.toString());
                    }

                    public void onError(int iLiveToken) {
                        System.out.println("Got error");
                    }

                    public void onUnsubscribe(int iLiveToken) {
                        System.out.println("Got unsubscribe");
                    }
                }));

                Integer token = result.get(0).field("token");
                System.out.println("Token: " + token);

                System.out.println("insert");
                db.command(new OCommandSQL("insert into test set name = 'foo', surname = 'bar'")).execute();

                System.out.println("wait");
                Thread.sleep(10000);

                System.out.println("unsubscribe");
                db.command(new OCommandSQL("live unsubscribe " + token)).execute();

                System.out.println("wait2");
                Thread.sleep(10000);
            } finally {
                db.close();
            }
        } finally {
            admin.dropDatabase("test");
            admin.close();
        }
    }
}

The output is:

Oct 20, 2017 2:13:26 PM com.orientechnologies.common.log.OLogManager log
WARNING: The Client driver version is different than Server version: client=36, server=37. You could not use the full features of the newer version. Assure to have the same versions on both
Create DB
LIVE
Oct 20, 2017 2:13:29 PM com.orientechnologies.common.log.OLogManager log
WARNING: The Client driver version is different than Server version: client=36, server=37. You could not use the full features of the newer version. Assure to have the same versions on both
Token: -681561439
insert
wait
Got result ORecordOperation [record=Test#26:-2{name:foo,surname:bar} v0, type=CREATE]
Oct 20, 2017 2:13:29 PM com.orientechnologies.common.log.OLogManager log
WARNING: Receiving invalid LiveQuery token: -681561439
unsubscribe
Got unsubscribe
wait2
Got error

Please notice the record=Test#26:-2.

@pvalsecc
Copy link
Author

pvalsecc commented Oct 20, 2017

Also, please, notice the WARNING about the invalid token.

@pvalsecc
Copy link
Author

My erlang test uses two different connections for the insert and the live select. Same problem.

@luigidellaquila
Copy link
Member

Hi @pvalsecc

There are a couple of points here:

Thanks

Luigi

@pvalsecc
Copy link
Author

pvalsecc commented Oct 23, 2017

Last time I've checked nothing like that was documented for the binary protocol v37.

I've tested with the Java libs version 3.0.0m2 with the same code and it's worse, I don't even get the insert notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants