Title: RocksDB read-write store: by_guid fails or returns another entity for added or changed GlobalIds · Issue #9827 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: RocksDB read-write store: by_guid fails or returns another entity for added or changed GlobalIds · Issue #9827 · IfcOpenShell/IfcOpenShell
X Title: RocksDB read-write store: by_guid fails or returns another entity for added or changed GlobalIds · Issue #9827 · IfcOpenShell/IfcOpenShell
Description: Version: ifcopenshell 0.9.0 (PyPI wheel) and 0.9.1a261005, macOS arm64, Python 3.12 and 3.13. Found while checking #9822. Summary On a read-write RocksDB store, by_guid is wrong for any GlobalId written after the store was opened: an ent...
Open Graph Description: Version: ifcopenshell 0.9.0 (PyPI wheel) and 0.9.1a261005, macOS arm64, Python 3.12 and 3.13. Found while checking #9822. Summary On a read-write RocksDB store, by_guid is wrong for any GlobalId wr...
X Description: Version: ifcopenshell 0.9.0 (PyPI wheel) and 0.9.1a261005, macOS arm64, Python 3.12 and 3.13. Found while checking #9822. Summary On a read-write RocksDB store, by_guid is wrong for any GlobalId wr...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/9827
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"RocksDB read-write store: by_guid fails or returns another entity for added or changed GlobalIds","articleBody":"**Version:** ifcopenshell 0.9.0 (PyPI wheel) and 0.9.1a261005, macOS arm64, Python 3.12 and 3.13. Found while checking #9822.\n\n## Summary\n\nOn a read-write RocksDB store, `by_guid` is wrong for any GlobalId written after the store was opened: an entity added with `create_entity`, or an existing entity whose `GlobalId` was changed. Depending on the model it either raises `Instance #N not found` for an id that was never used, or returns a different, unrelated entity with no error. GlobalIds that were in the file when it was converted resolve correctly.\n\n## Reproduction\n\n```python\nimport ifcopenshell, ifcopenshell.api.root, ifcopenshell.guid, os, shutil, sys, tempfile\nprint(\"ifcopenshell\", ifcopenshell.version)\nsrc = sys.argv[1]\nd = tempfile.mkdtemp()\nconv = os.path.join(d, \"m.converting\"); rdb = os.path.join(d, \"m.rdb\")\nifcopenshell.convert_path_to_rocksdb(src, conv); os.rename(conv, rdb)\nf = ifcopenshell.open(src)\nroots = f.by_type(\"IfcRoot\")\ng = ifcopenshell.open(rdb, readonly=False)\nok = 0\nfor e in roots:\n try:\n if g.by_guid(e.GlobalId).id() == e.id(): ok += 1\n except Exception: pass\nprint(\"existing guids resolved:\", ok, \"of\", len(roots))\nnew_guid = ifcopenshell.guid.new()\nw = g.create_entity(\"IfcBuildingElementProxy\", GlobalId=new_guid, Name=\"ADDED\")\nprint(\"added: id\", w.id(), \"class\", w.is_a())\ntry:\n r = g.by_guid(new_guid)\n print(\"by_guid(new) ->\", \"id\", r.id(), r.is_a(), getattr(r, \"Name\", None), \"| same entity:\", r.id() == w.id())\nexcept Exception as ex:\n print(\"by_guid(new) raised:\", type(ex).__name__, ex)\ne0 = g.by_id(roots[0].id()); changed = ifcopenshell.guid.new(); e0.GlobalId = changed\ntry:\n r = g.by_guid(changed)\n print(\"by_guid(changed) ->\", \"id\", r.id(), r.is_a(), \"| same entity:\", r.id() == e0.id())\nexcept Exception as ex:\n print(\"by_guid(changed) raised:\", type(ex).__name__, ex)\nshutil.rmtree(d, ignore_errors=True)\n```\n\nRun as `python repro.py model.ifc`. Results, identical on 0.9.0 and 0.9.1a261005:\n\n| Model | existing GlobalIds | `by_guid` of an added entity | `by_guid` after changing a GlobalId |\n|---|---|---|---|\n| `test/input/539--rotated-studs--augmented.ifc` (IFC4, 9,937 entities) | 2341 of 2341 | `RuntimeError: Instance #24780 not found` (the added entity is #11752) | `RuntimeError: Instance #22439 not found` |\n| `test/input/706--buildingElementProxy--segfault--accept-errors.ifc` (IFC2X3, 638,340 entities) | 2 of 2 | returns #1276699, an IfcCartesianPoint (the added entity is #2002798) | returns #1276697, an IfcCartesianPoint |\n\nThe second row is the dangerous one: a lookup by GlobalId hands back another entity.\n\n## Likely cause (read from the source, not confirmed by a build)\n\n`src/ifcparse/file.cpp:161` on v0.9.0:\n\n```cpp\nbyguid_(&byguid_internal_, [this](size_t v) { return assert_existance(v, entityinstance_ref); }, [](const express::base& v) { return v.identity(); })\n```\n\nThe write side stores `v.identity()`, while the read side looks the stored number up as an instance name. The streaming converter writes instance names under `g|` (74b405a9f7), which is why converted GlobalIds resolve. The next line carries a `@todo by_identity is probably not correct here`.\n\n## Expected\n\n`by_guid` returns the entity that carries the GlobalId, or raises if none does.\n\nNot tested: Linux and Windows wheels for this case, and the tip of v0.9.0 beyond the 261005 alpha.\n","author":{"url":"https://github.com/petruconduraru","@type":"Person","name":"petruconduraru"},"datePublished":"2026-10-06T11:06:20Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/9827"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f39811b5-7077-f353-dd36-f863e4a44b74 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFDE:124D68:2CCC36:3D96A2:6B04B9F8 |
| html-safe-nonce | 8b97e4518c9306c6356ab5ff92fabc60071701b4c2d1ebc6717b57c8592f6c55 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkRFOjEyNEQ2ODoyQ0NDMzY6M0Q5NkEyOjZCMDRCOUY4IiwidmlzaXRvcl9pZCI6IjQzMjE4MTMwMjk1MzM4MjU1MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a4e84245c5b9c14d0baeb3a34d266a3450cb272538814cb8d94d63ee4e7f61ca |
| hovercard-subject-tag | issue:5727321272 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/9827/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d6491ea7179eedde3ba092d5fe9c22c96126866ff18d5dd68f56e6ced854554/IfcOpenShell/IfcOpenShell/issues/9827 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d6491ea7179eedde3ba092d5fe9c22c96126866ff18d5dd68f56e6ced854554/IfcOpenShell/IfcOpenShell/issues/9827 |
| og:image:alt | Version: ifcopenshell 0.9.0 (PyPI wheel) and 0.9.1a261005, macOS arm64, Python 3.12 and 3.13. Found while checking #9822. Summary On a read-write RocksDB store, by_guid is wrong for any GlobalId wr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | petruconduraru |
| hostname | github.com |
| expected-hostname | github.com |
| None | 378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7 |
| turbo-cache-control | no-preview |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b032e77f1ea437ede6c115446a0a467709b468e7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width