Repository navigation
Read a copy of the data file while data updates can replace it - #195
Draft
jwrosewell wants to merge 8 commits into
Draft
jwrosewell wants to merge 8 commits into
jwrosewell wants to merge 8 commits into
Conversation
A refresh swapped in the new data set but kept everything the engine had taken from the old one. The Device Detection engine went on listing and reading only the old file's properties, under the old tier, so a Lite engine updated to an Enterprise file reported 22 properties, the tier Lite, and no value for the properties the Lite file lacks. The IP Intelligence engine went on reporting the old tier and publish date. Each engine now keeps the properties a detection reads with the data set they belong to, and replaces its property metadata and tier when a data file with others is loaded. The pipeline traits lend those by reference for as long as the engine lives, so each one replaced is kept rather than freed. A refresh records the IP Intelligence file's publish date, and refreshes run one at a time.
This was referenced Oct 27, 2026
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #167.
Builds on #194, whose commits it carries, because both change how each engine keeps its loaded data set. Merge #194 first, and this pull request then shows its own change alone.
Problem
Every profile but
InMemoryreads the data file while its data set lives, through handles the native library opens without delete sharing (common-sys/vendor/common-cxx/file.cline 169), and both engines opened the data file itself. On Windows an update cannot rename the new file over a file open that way, so with automatic updates on, an update underDefault,LowMemoryorHighPerformancedownloaded the whole file and failed withNewFileCannotRename, and the next poll did the same. The specification makes an operational data copy necessary for disk based operation with automatic updates on (data-updates.md lines 249 to 252), and .NET documents its temporary copy as required for automatic updates when the data is not all in memory. #167 has the details.Change
InMemory, each engine copies the data file into the temporary folder and reads the copy, so the data file itself is never held open. A refresh copies the new file the same way.How it was verified
New tests:
an_update_replaces_the_data_file_under_every_profile, indevice-detection-onpremise/tests/operational_copy.rswith the Lite Hash file and inip-intelligence-onpremise/tests/operational_copy.rswith the ASN file, updates a running engine from a local server underDefault,Balanced,LowMemory,HighPerformanceandInMemory, and checks the update succeeds, the engine still detects or looks up, and nothing is left behind once the engine is dropped.each_copy_goes_with_the_data_set_read_from_it(device-detection-onpremise/tests/operational_copy.rs) counts the copies while an early detection outlives three refreshes, after it is dropped, and after the engine is dropped.Before the change, on a branch holding only the new tests, all three fail. Under
Defaulteach update fails withdata update failed (NewFileCannotRename): error writing data file '...\51Degrees.hash': Access is denied. (os error 5), for the Device Detection engine and the IP Intelligence engine alike, and no copy is made (one copy for the data set loaded,left: 0, right: 1). After it, all three pass.Locally on Windows, with all seven fixes of this sweep merged together (#175, #178, #182, #184, #194, #195 and #196),
cargo test --no-fail-fast -p fiftyone-pipeline-engines -p fiftyone-device-detection-onpremise -p fiftyone-ip-intelligence-onpremise -p fiftyone-device-detection -p fiftyone-ip-intelligence -- --nocapture, with51DEGREES_DD_PATHnaming the Lite Hash file,Enterprise-HashV41.hashbeside it, and51DEGREES_IPI_PATHnaming the ASN file,51Degrees-LiteV41.ipibeside it, gives 130 passed, 0 failed and 2 ignored across 24 test binaries. With the fixes merged,cargo doc --workspace --no-depswithRUSTDOCFLAGS="-D warnings"passes, andrustfmt --checkpasses on every file the seven fixes change.cargo clippy --workspace --all-targets -- -D warningson the merged fixes has not run yet. ThePull Requestworkflow, which builds and tests each pull request on every platform, is waiting for approval to run.Behaviour that changes
With automatic updates on and any profile but
InMemory, an engine needs free space in the temporary folder for a copy of its data file, two while a refresh loads a new one, and takes the time to copy the file when it is built and on each refresh. In return an update can replace the data file on Windows.What remains
std::env::temp_dir(). .NET and the specification let the caller choose the folder. A setting for it would be new public API, so it is left for a decision.