fix(arcadedb): clone() must switch database, or a tenant switch reads the wrong tenant - #4
Open
g33kroid wants to merge 1 commit into
Conversation
… the wrong tenant GraphDriver.clone() returns self. Every other driver overrides it; the ArcadeDB driver did not, so clone() was a no-op here. That default is wrong on ArcadeDB specifically, because a database is the tenant boundary on this backend rather than a filter over one shared store: per-tenant databases are the reason to pick it. graphiti calls clone(group_id) to switch tenant, so with clone() returning self every subsequent query stayed on the previous tenant's database. Nothing raises — the query is valid, the database simply does not hold that tenant's rows — so the caller sees an empty tenant instead of an error, and any code that treats "no results" as "nothing to do" writes a second copy into the wrong database. Found running graphiti's search suite across ArcadeDB, Neo4j and FalkorDB on ArcadeDB 26.9.1: the per-tenant switch returned 0 rows on ArcadeDB and the expected rows on the other two. The Bolt client is shared with the original driver. It is not bound to a database — session() and execute_query() both take database_ per call — so sharing it matches the other drivers, and closing one clone closes them all as it does elsewhere. Two regression tests: clone() returns a distinct driver on the requested database without disturbing the original, and a cloned driver's session() opens on the cloned database.
6 tasks
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.
GraphDriver.clone()returnsself. Every other driver overrides it;ArcadeDBDriverdoes not, soclone()is a no-op here.That default is wrong on ArcadeDB specifically. On this backend a database is the tenant boundary — which is a large part of why it is attractive next to Neo4j CE, where tenancy falls back to a
group_idfilter over one shared store. graphiti callsclone(group_id)to switch tenant, so withclone()returningself, every subsequent query stays on the previous tenant's database.Nothing raises. The query is valid and the database simply does not hold that tenant's rows, so the caller sees an empty tenant rather than an error — and any code that reads "no results" as "nothing there yet" will write a second copy into the wrong database.
How it showed up
Running graphiti's search suite across ArcadeDB, Neo4j and FalkorDB on ArcadeDB 26.9.1 (
sha256:02a1a74f…), driver at92ab811. Same data, same checks, three engines:0 hitswhere the tenant plainly has matching rows. With this fix, the same suite is 15/15 on ArcadeDB.The fix
clone()returns a driver bound to the requested database. The Bolt client is shared with the original: it is not bound to a database —session()andexecute_query()both takedatabase_per call — so sharing it matches the other drivers, and closing one clone closes them all, as it does elsewhere.Tests
Two regression tests in the existing
tests/driver/test_arcadedb_driver.pystyle, no server needed:test_clone_switches_database—clone()returns a distinct driver on the requested database, leaves the original alone, shares the clienttest_clone_session_targets_cloned_database— a cloned driver'ssession()opens on the cloned databaseBoth fail on the current head (
assert cloned is not self.driver) and pass with the fix. Full file: 25 passed, 1 skipped.Unrelated, but found in the same run
Similarity search is still broken on this branch's head — the group/uuid filter emits
WHERE …, then the embedding guard is concatenated as a secondWHERE, so node/edge/community similarity all raiseCypherSyntaxError: Unexpected input 'WHERE'whenever any filter is present, which in a multi-tenant deployment is always. #2 already fixes exactly this and has been open since July, so I have deliberately not duplicated it here — it may just need merging.🤖 Generated with Claude Code