Overview
If you have an object type that is connected to an external database, you may see a new version created for each object in the vault every time the full refresh runs (which by default happens at least once every night during the nightly maintenance of the vault).
If you compare these object versions (for example, open the History dialog for an object and select two versions), you will likely see their metadata is the same - no properties changed (if they change, the value will be "(varies)" instead of the actual value).
Over time you can easily end up with thousands of versions of the same object. When you multiply this by thousands of objects, you will get a slowdown in the vault and a database bloat. In addition, the refresh operations are much slower than expected because they create new versions for every object.
End users may also be unable to edit objects: /article/Unable-to-Update-External-Object-Metadata-Card.
Cause
The reason for this is typically custom code in the vault that alters the values coming in from the external database before putting them in the vault database.
Such code could be calculated property (via a script or vault app), validation script that alters values (which should not be done in general), Managed Property from Compliance Kit configuration, or vault event handlers.
Here is a sample scenario where this can happen:
- The external database for object X has value "a" in column1.
- Code in the vault changes that property to "abcd" based on business logic.
- When the external object refresh happens, the M-Files server detects a difference for that object X - the vault has "abcd" but the external database has "a". So, M-Files makes a new version of this object, trying to update the property to "a".
- The custom script/code kicks in and changes that "a" to "abcd" again, so you see no change in the metadata between the versions, but a version was created regardless.
Solution
Do not alter data coming from the external database before storing it into the vault, instead just validate it and bail out with an error if the data being stored is not something it should be.
Note that if you have had such an issue, once you remove its cause, the next full refresh will still be as slow, and will still create a new version - this version will have the actual external database value as it should have had from the beginning. Subsequent refreshes will no longer be as slow or create versions for all objects unnecessarily. Also, be aware that some datatypes, for example real/floating point numbers or timestamps can have unexpected behavior if one of the systems uses higher accuracy than the other.
Note 2: There can be multiple properties causing this behavior, and their sources may be different. Check your vault metadata structure carefully.
Note 3: If you have had this issue, you may need to remove the excess versions from your vault. We have a tool called Version Deleter for this - please contact our support for details.
