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

Distributed: asynchronous inserts ignore unique indexes #2914

Closed
nethertek opened this issue Oct 11, 2014 · 14 comments
Closed

Distributed: asynchronous inserts ignore unique indexes #2914

nethertek opened this issue Oct 11, 2014 · 14 comments
Assignees
Milestone

Comments

@nethertek
Copy link

Applying a unique index such as

"create index sms_keys ON SMS (type, lang) unique"

is ignored during inserts in distributed asynchronous mode.

@lvca
Copy link
Member

lvca commented Oct 13, 2014

Fixed in 9804c47 and deployed in last 2.0-SNAPSHOT.

@lvca lvca closed this as completed Oct 13, 2014
@lvca lvca assigned lvca and unassigned andrii0lomakin Oct 13, 2014
@lvca lvca added this to the 2.0 Final milestone Oct 13, 2014
@lvca lvca modified the milestones: 2.0 Final, 2.0-M3 Nov 13, 2014
@nethertek
Copy link
Author

The issue is again present in version 2.0.9, 2.0.12. Whilst the index is created, it is ignored during insert in distributed mode.

Once duplicates have been inserted, rebuilding the index will cause an exception as expected.

@lvca
Copy link
Member

lvca commented Jul 22, 2015

I cannot reproduce it. Do you have a test case?

@nethertek
Copy link
Author

Creating database [remote:localhost/test] using the storage type [plocal]...
Disconnecting from the database [backnodeee]...OK
Connecting to database [remote:localhost/test] with user 'admin'...OK

DISTRIBUTED CONFIGURATION:
{
  "members": [{
      "id": "57c61537-d5d8-418e-b97a-0867eb5202e3",
      "name": "missouri",
      "startedOn": "2015-07-22 13:04:09",
      "listeners": [{"protocol":"ONetworkProtocolBinary","listen":"50.30.34.105:2424"},{"protocol":"ONetworkProtocolHttpDb","listen":"50.30.34.105:2480"}],
      "databases": []
      },{
      "id": "c72e82e5-d9ef-4571-8b46-c92d82db2abd",
      "name": "tirpitz",
      "startedOn": "2015-07-22 13:06:20",
      "listeners": [{"protocol":"ONetworkProtocolBinary","listen":"148.251.77.75:2424"},{"protocol":"ONetworkProtocolHttpDb","listen":"148.251.77.75:2480"}],
      "databases": []
      }
  ],
  "localName": "_hzInstance_1_orientdb",
  "localId": "c72e82e5-d9ef-4571-8b46-c92d82db2abd"
}
Database created successfully.

Current database is: remote:localhost/test
orientdb {db=test}> create class SMS;

Class created successfully. Total classes in database now: 11

orientdb {db=test}> create property SMS.type string

Property created successfully with id=1

orientdb {db=test}> create property SMS.lang string

Property created successfully with id=2

orientdb {db=test}> create property SMS.source integer

Property created successfully with id=3

orientdb {db=test}> create property SMS.content string

Property created successfully with id=4

orientdb {db=test}> alter property SMS.lang min 2

Property updated successfully

orientdb {db=test}> alter property SMS.lang max 2

Property updated successfully

orientdb {db=test}> create index sms_keys ON SMS (type, lang) unique


Creating index...
Created index successfully with 0 entries in 1.663000 sec(s).


Index created successfully
orientdb {db=test}> 

orientdb {db=test}> insert into sms (type, lang, source, content) values ( 'notify', 'en', 1, 'This is a test');

Inserted record 'SMS#14:0{type:notify,lang:en,source:1,content:This is a test} v1' in 0.014000 sec(s).

orientdb {db=test}> insert into sms (type, lang, source, content) values ( 'notify', 'en', 1, 'This is a test');

Inserted record 'SMS#14:1{type:notify,lang:en,source:1,content:This is a test} v1' in 0.033000 sec(s).

orientdb {db=test}> insert into sms (type, lang, source, content) values ( 'notify', 'en', 1, 'This is a test');

Inserted record 'SMS#14:2{type:notify,lang:en,source:1,content:This is a test} v1' in 0.289000 sec(s).

orientdb {db=test}> insert into sms (type, lang, source, content) values ( 'notify', 'en', 1, 'This is a test');

Inserted record 'SMS#14:3{type:notify,lang:en,source:1,content:This is a test} v1' in 0.005000 sec(s).

orientdb {db=test}> select * from SMS

----+-----+------+------+----+------+--------------
#   |@RID |@CLASS|type  |lang|source|content       
----+-----+------+------+----+------+--------------
0   |#14:0|SMS   |notify|en  |1     |This is a test
1   |#14:1|SMS   |notify|en  |1     |This is a test
2   |#14:2|SMS   |notify|en  |1     |This is a test
3   |#14:3|SMS   |notify|en  |1     |This is a test
----+-----+------+------+----+------+--------------

4 item(s) found. Query executed in 0.007 sec(s).
orientdb {db=test}> rebuild index *


Rebuilding index(es)...
Error: com.orientechnologies.orient.server.distributed.ODistributedException: Error on execution distributed COMMAND

Error: com.orientechnologies.orient.core.index.OIndexException: Error on rebuilding the index for clusters: [sms]

Error: com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #14:1: found duplicated key 'OCompositeKey{keys=[notify, en]}' in index 'sms_keys' previously assigned to the record #14:0 RID=#14:0

orientdb {db=test}> 

@lvca
Copy link
Member

lvca commented Jul 30, 2015

Thanks, working on it...

@lvca
Copy link
Member

lvca commented Jul 30, 2015

Reproduced with a Java test case.

@testark
Copy link

testark commented Nov 30, 2015

@lvca This is still the case with 2.1.6.

lvca added a commit that referenced this issue Dec 1, 2015
@testark
Copy link

testark commented Dec 1, 2015

@lvca In this line

I see plocal. I am using remote so, believe me this is still the case.

@lvca
Copy link
Member

lvca commented Dec 1, 2015

Created new test case (e2b40ee) with 3 servers and remote and pass...

lvca added a commit that referenced this issue Dec 1, 2015
@testark
Copy link

testark commented Dec 1, 2015

The test case deals with the document API. I'm using the Graph API.

@lvca
Copy link
Member

lvca commented Dec 3, 2015

You're right, I was able to reproduce it with 3 nodes, async replication through remote protocol call and graph API that always start a distributed transaction. Working to the fix.

@lvca lvca modified the milestones: 2.1.x (next hotfix), 2.0.14 Dec 3, 2015
@testark
Copy link

testark commented Dec 3, 2015

@lvca See? :-) I was not trying to be mean or something, just reporting because it is still indeed the case. Glad you can work on that.

lvca added a commit that referenced this issue Dec 4, 2015
@lvca
Copy link
Member

lvca commented Dec 4, 2015

Fixed in 2.1.x

@lvca lvca closed this as completed Dec 4, 2015
@lvca lvca removed the in progress label Dec 4, 2015
@lvca lvca modified the milestones: 2.1.x (next hotfix), 2.1.7 Dec 6, 2015
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