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

Fixes Shared Database: Changes filtering in CoarseChangeFilter to attribute property #6868

Merged
merged 6 commits into from
Sep 26, 2020

Conversation

m-mauersberger
Copy link
Contributor

WIth further investigations on the already closed issue #6663 I changed the function of CoarseChangeFilter.java. Following problems I encountered with the actual version:

  • The database sometimes hangs up when an actual event (directly via eventBus.post) triggers database synchronization at the same time as a delayed event (delayed via delayPost.schedule). Apparently, this should be avoided.
  • Delaying an event post via DelayTaskThrottler causes the subsequent actions on event listening (e.g. in DBMSSynchronizer) to run on a new thread concurrently. If I have a large shared library (~5600 entries), it takes some seconds to pull changes. A delayed event that induces database synchronization ignores all field changes within synchronization time. These are then lost.
  • There is no other option fetching non-saved field changes because these events are completely filtered out. DBMSSynchronizer does not see them at all.

My new proposal includes an additional attribute filteredOut in BibDatabaseContextChangedEvent. You can set it if the event may be filtered out by a listening method. The corresponding constructor has to be called in every child class (e.g. MetaDataChangedEvent or EntriesEvent). The according functionality has been updated in AutosaveManager and BackupManager.

How can the remaining field changes be saved that are marked by filteredOut == true? I tried to introduce a lastEntryChanged attribute in DBMSSynchronizer that indicate which BibEntry these unsaved changes are bound to. At every event that has been listened to last entry changes are synchronized via pullWithLastEntry. Finally, unsaved field changes are also caught at closing the shared database. So DBMSSynchronizer.closeSharedDatabase calls pullLastEntryChanges. This method only synchronizes the database if unsaved field changes still remain.

Maybe you could look at the proposals. The main reason for that changes is that delayed event post does not work with synchronization of large shared databases.

PS: DelayTaskThrottler has been extended by a method to immediately run a previously scheduled task. This had be done in accordance to the possibility of the executor service ScheduledThreadPoolExecutor.

…ChangedEvent (filteredOut): true - event may be filtered out, false - event may not be filtered out

BibDatabaseContextChangedEvent got a filteredOut attribute to account for general event filtering. Super class constructors are called within inheriting classes.

Last FieldChangedEvents that has not been synchronized (due to filteredOut==true) are synchronized at any other event in DBMSSynchronizer or closing the database( DBMSSynchronizer.closeSharedDatabase).
@m-mauersberger m-mauersberger marked this pull request as ready for review September 4, 2020 08:33
@m-mauersberger m-mauersberger changed the title Shared Database: Changes filtering in CoarseChangeFilter to attribute property Fix Shared Database: Changes filtering in CoarseChangeFilter to attribute property Sep 14, 2020
@m-mauersberger m-mauersberger changed the title Fix Shared Database: Changes filtering in CoarseChangeFilter to attribute property Fixes Shared Database: Changes filtering in CoarseChangeFilter to attribute property Sep 14, 2020
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can follow your line of argumentation.

The comments should go to a new file remote-storage.md in https://github.com/JabRef/jabref/tree/master/docs/advanced-reading.

Can you please also look at the failing tests (checkstyle and database).

I am not sure whether following failures are related to your changes - or whether you can just fix them :)

Another thing: Is the magic number 30 covered by any test case or can you think of a test setup of an automated test?

grafik

@koppor koppor added the status: changes required Pull requests that are not yet complete label Sep 20, 2020
m-mauersberger and others added 4 commits September 25, 2020 10:16
CoarseChangeFilter: Remove totalDelta due to restriction to pasting and deleting more than one character. Handle changed field.
DBMSSynchronizer: Pull remaining changes at every entry-related event.
CoarseChangeFilter: Remove totalDelta due to restriction to pasting and deleting more than one character. Handle changed field.
DBMSSynchronizer: Pull remaining changes at every entry-related event.
# Conflicts:
#	src/main/java/org/jabref/logic/util/CoarseChangeFilter.java
@m-mauersberger
Copy link
Contributor Author

m-mauersberger commented Sep 25, 2020

Thank you very much for review!

I tried to get in line with your change requests changing some lines in CoarseChangeFilter.java and DBMSSynchronizer.java.

  • In CoarseChangeFilter I had a misinterpretation of major changes. Now I restored the value 1 as before Shared PostgreSQL database not fully syncing user inputs #6663 - and I understood that it was meant to represent pasting and deleting text implicitly. After some manual tests I added a check whether a new BibEntry is edited. If you edited the same field on another entry, there was no change recognized at all.

  • In DBMSSynchronizer I added pullWithLastEntry to every entry-related event in order to consider non-saved changes in fields before adding or removing another entry. I must admit that I do not fully understand why new entries are added after (listen(EntriesAddedEvent event))while entries are removed before metadata and database synchronization (listen(EntriesRemovedEvent event)). Furthermore, lastEntryChanged is assigned as non-empty after adding an entry although it was empty before (ensured by pullWithLastEntry). Maybe some FieldChangedEvents are posted after adding an entry?

Unfortunately I could not resolve the failing database tests. SharedEntriesNotPresentEvents and UpdateRefusedEvents are fired when synchronizing database or accordingly shared entries. Maybe it has something to do with the correct order of synchronization commands (as mentioned above)?

Following manual tests worked when using the database for myself:

Proper synchronization after:

  • Add entry.
  • Remove entry.
  • Add entry after typing something without synchronization.
  • Remove entry after typing something without synchronization.
  • Typing on the same entry in another field.
  • Typing on another entry in the same field.
  • Typing on another entry in another field.
  • Pasting something more than 1 character.

I would be glad if you could help me fix the remaining failed tests. Maybe you have an idea about that.

@koppor koppor merged commit a0ca875 into JabRef:master Sep 26, 2020
@koppor
Copy link
Member

koppor commented Sep 26, 2020

Thank you for the work. This is a huge step forward. Thank you for documenting your tests. I hope, we can inspect why test cases fail.

@m-mauersberger m-mauersberger deleted the socketTimeOut branch September 26, 2020 09:08
Siedlerchr added a commit that referenced this pull request Sep 26, 2020
…-issue-6707

* upstream/master: (35 commits)
  Fix a fetcher test for the ShortDOIService (#6945)
  Fixes Shared Database: Changes filtering in CoarseChangeFilter to attribute property (#6868)
  Changed default value of "search and store files relative to bibtex file" to true (#6928)
  Replace comment by just a failure (#6943)
  Fix: in entry types editor selected field is not removed after first click  (#6941)
  Fix remove actions for entry types in the editor (#6933)
  Always use Java 15 (#6929)
  Update DevDocs: workaround for issues with local openjfx maven libraries (#6931)
  Fixes bugs in the `regex` cite key pattern modifier (#6893)
  Add missing author
  Readability for citation key patterns (#6706)
  Add new author
  Reset to master and add default case to switch (#6847)
  Bump mockito-core from 3.5.10 to 3.5.11 (#6924)
  Bump byte-buddy-parent from 1.10.14 to 1.10.15 (#6923)
  Bump org.beryx.jlink from 2.21.4 to 2.22.0 (#6925)
  Bump xmpbox from 2.0.20 to 2.0.21 (#6926)
  Bump pascalgn/automerge-action from v0.9.0 to v0.10.0 (#6927)
  Improve parsing of short DOIs (#6920)
  Bump junit-vintage-engine from 5.6.2 to 5.7.0 (#6910)
  ...
Siedlerchr added a commit that referenced this pull request Sep 26, 2020
* upstream/master: (55 commits)
  Rename menus citation style in preview style (#6899)
  Fix for some Unicode characters in citation keys (#6938)
  Add missing authors
  Fix a fetcher test for the ShortDOIService (#6945)
  Fixes Shared Database: Changes filtering in CoarseChangeFilter to attribute property (#6868)
  Changed default value of "search and store files relative to bibtex file" to true (#6928)
  Replace comment by just a failure (#6943)
  Fix: in entry types editor selected field is not removed after first click  (#6941)
  Fix remove actions for entry types in the editor (#6933)
  Always use Java 15 (#6929)
  Update DevDocs: workaround for issues with local openjfx maven libraries (#6931)
  Fixes bugs in the `regex` cite key pattern modifier (#6893)
  Add missing author
  Readability for citation key patterns (#6706)
  Add new author
  Reset to master and add default case to switch (#6847)
  Bump mockito-core from 3.5.10 to 3.5.11 (#6924)
  Bump byte-buddy-parent from 1.10.14 to 1.10.15 (#6923)
  Bump org.beryx.jlink from 2.21.4 to 2.22.0 (#6925)
  Bump xmpbox from 2.0.20 to 2.0.21 (#6926)
  ...

# Conflicts:
#	src/main/java/org/jabref/logic/util/DelayTaskThrottler.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: changes required Pull requests that are not yet complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants