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

[Blameable] Remove scheduleExtraUpdate calls #320

Closed

Conversation

EmmanuelVella
Copy link
Contributor

@EmmanuelVella EmmanuelVella commented Aug 10, 2016

Issue

BlameableSubscriber (at least) is always doing an extra database update after inserting/updating an entity. It seems to be caused by the scheduleExtraUpdate calls.

This is especially annoying because I use doctrine version locking, and the version is incrementing 2 by 2.

Examples (simplified)

Insert

INSERT INTO my_table (created_by_id, updated_by_id) VALUES (?, ?) {"3":2,"4":2}
UPDATE my_table SET created_by_id = ?, version = version + 1 WHERE id = ? AND version = ? [2,503,1]

Update

UPDATE my_table SET updated_by_id = ?, version = version + 1 WHERE id = ? AND version = ? [2,502,6]
UPDATE my_table SET updated_by_id = ?, version = version + 1 WHERE id = ? AND version = ? [2,502,7]

Solution

Removing these calls fixes the issue : only 1 insert or update is performed, and the createdBy and updatedBy are inserted/updated correctly.

Examples (simplified)

Insert

INSERT INTO my_table (created_by_id, updated_by_id) VALUES (?, ?) {2, 2}

Update

UPDATE my_table SET updated_by_id = ?, version = version + 1 WHERE id = ? AND version = ? [2,502,2]

Conclusion

I'm not sure about the side effects of removing this call, please feel free to comment this PR !

@hectorh30
Copy link

I'm having an issue with these extra database calls too, mainly because of the logging behavior: I'm getting twice the amount of logs I'd expect.

As far as I could dig into, this behaviour was introduced in ca44b17, but I don't know how to find what was the first release to include the commit, so as to look for any reference.

Are there any side effects to removing the scheduled extra updates?

@docteurklein
Copy link
Contributor

docteurklein commented Sep 8, 2016

thanks for the detailled explanation!

I wonder if we added these extra updates because of some edge cases.
I just don't remember so we'd need to add tests in order to avoid any regression.
Would you have time to add some tests?

@EmmanuelVella
Copy link
Contributor Author

Hey, I will try to add some tests in the next days. Thanks for feedback !

@EmmanuelVella
Copy link
Contributor Author

Hi, I won't have time to work on this at the moment. If someone want to create some tests, feel free to duplicate my PR ;)

@EmmanuelVella EmmanuelVella force-pushed the scheduleExtraUpdate branch 2 times, most recently from d018cdf to 29d5252 Compare April 5, 2018 15:44
@EmmanuelVella
Copy link
Contributor Author

Hello, after a long time I finally decided to update my PR with tests !

I fixed Blameable and Geocodable and also added tests for SoftDeletable (this one needs the scheduleExtraUpdate call).

Could someone please have a look ? Thank you !

@EmmanuelVella
Copy link
Contributor Author

ping @docteurklein do you still work on this project ?

@EmmanuelVella
Copy link
Contributor Author

Hey there ;) Could someone please check (and merge?) this PR please ? Thank you !

@TomasVotruba
Copy link
Contributor

Could you rebase on current master? I'll merge it right away :)

@TomasVotruba TomasVotruba changed the title Remove scheduleExtraUpdate calls [Blameable] Remove scheduleExtraUpdate calls Dec 18, 2019
@TomasVotruba
Copy link
Contributor

I made huge refactoring on adding types in methods and properties, voids, scalars, array etcs., so basically I had to recreate every interface from scratch.
Saying that, this feature was cherry picked and merged in #464

Thanks for your work 👍

@EmmanuelVella
Copy link
Contributor Author

Sorry, I was going to rebase it soon. Great you could cherry-pick it ! 👍

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

Successfully merging this pull request may close these issues.

None yet

5 participants