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

LINKSET within transaction: fails to remove newly created records. #8634

Closed
foriam opened this issue Oct 28, 2018 · 9 comments
Closed

LINKSET within transaction: fails to remove newly created records. #8634

foriam opened this issue Oct 28, 2018 · 9 comments
Assignees
Labels
Milestone

Comments

@foriam
Copy link

foriam commented Oct 28, 2018

OrientDB Version: 3.0.9 edit: 3.0.10

Java Version: 8-191

OS: MacOS

Expected behavior

When adding and subsequently removing a record to a LINKSET within a transaction, it should not be there after commit.

Actual behavior

When adding and subsequently removing a record to a LINKSET within a transaction, it is there again after commit.

Steps to reproduce

See the following test written in groovy using the Java API:


/*
   Structure:

   WithLinks {
       links: [Linked]
   }
*/
OClass withLinks = db.createClass("WithLinks")
withLinks.createProperty("links", OType.LINKSET)
OClass linked = db.createClass("Linked")

/* A link must already be there */
OElement withLinks1 = db.newInstance("WithLinks")
OElement link1 = db.newInstance("Linked")
link1.save()
withLinks1.setProperty("links", [link1].toSet())
withLinks1.save()

/* Only in transaction - without transaction all OK */
db.begin()
    OElement withLinks1InTrans = db.load(withLinks1.identity)

    /* Add a new linked record */
    OElement link2 = db.newInstance("Linked")
    link2.save()
    withLinks1InTrans.getProperty("links").add(link2)
    withLinks1InTrans.save()

    /* Remove all from ORecordLazySet - if only link2 removed all OK */
    withLinks1InTrans.getProperty("links").remove(link1)
    withLinks1InTrans.getProperty("links").remove(link2)
    withLinks1InTrans.save()

    /* All seems OK before commit */
    assert withLinks1InTrans.getProperty("links").size() == 0
    assert withLinks1.getProperty("links").size() == 0
db.commit()

/* No difference if reload or not */
withLinks1 = withLinks1.reload()

/* Initial record was removed */
assert !withLinks1.getProperty("links").contains(link1)
/* Fails: why is link2 still in the set? */
assert !withLinks1.getProperty("links").contains(link2)

While the flow of adding and removing within one transaction is not something you'd intentionally do, it is impossible to prevent when using an object mapping layer and complex operations on persisted objects. Can lead to serious and in the worst case long unnoticed bugs.

@mmacfadden
Copy link
Contributor

mmacfadden commented Oct 28, 2018

@foriam I think this might be related too or a duplicate of another issue I just posted yesterday. #8632

Except in my case, the link that is trying to be updated is not for a newly created item.

What do you think?

@foriam
Copy link
Author

foriam commented Oct 29, 2018

@mmacfadden Maybe! Critical differences, however:

  • This issue does not exist if both elements of LINKSET are created either inside or outside the transaction.
  • The above test runs through with a LINKMAP (as in execute() in transactions doesn't UPDATE records #8632), as well as with a LINKLIST - it seems an issue specific to LINKSET.
  • This issue is exists for PLOCAL as well as MEMORY dbs.

So it would rather be an indirect relationship to the same root cause.

@mmacfadden
Copy link
Contributor

@foriam Thanks for the insight. If the OrientDB team doesn't look into them in the next day or so I will probably take a stab and figuring both of these out.

@foriam
Copy link
Author

foriam commented Nov 13, 2018

Is there any update on this bug? Has anyone from the OrientDB team checked these issues and can comment how they could be addressed? Thanks!

@mmacfadden
Copy link
Contributor

@luigidellaquila @tglman Any thoughts on this one as well as perhaps #8632?

@luigidellaquila
Copy link
Member

Hi @mmacfadden @foriam

I'm working on it now, I'll let you know asap

Thanks

Luigi

@luigidellaquila luigidellaquila self-assigned this Nov 29, 2018
@mmacfadden
Copy link
Contributor

@luigidellaquila Thanks for the update. I am hopeful that the fix might also take care of #8632.

@mmacfadden
Copy link
Contributor

Also, if you nee any help testing let me know.

luigidellaquila added a commit that referenced this issue Nov 29, 2018
@luigidellaquila
Copy link
Member

Hi @mmacfadden @foriam

I pushed the fix, it will be released with v 3.0.12
I'm checking the other issue, but I doubt that the cause is the same...

Thanks

Luigi

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

No branches or pull requests

3 participants