Repository navigation
Description
Follow-up to #7477 / PR #7478. TRUNCATE TYPE on a LIGHTWEIGHT edge type currently refuses (added in that PR); it should delete the edges.
Why it refuses today
TruncateTypeStatement.executeDDL deletes what Database.scanType() finds, and LocalDatabase.scanType iterates type.getBuckets(polymorphic) and reads those bucket pages directly. It never goes through SelectExecutionPlanner, so the vertex walk #7477 gave SELECT and DELETE FROM does not reach it.
A lightweight edge allocates no record, so that bucket is empty by construction. Before #7478 the statement therefore reported success having deleted nothing:
> select count(*) from Cite
{c: 2}
> truncate type Cite
{operation: truncate type, typeName: Cite, transactional: true}
> select count(*) from Cite
{c: 2}
That is the failure #7477 is about, in its worse form: a caller who believes a bulk delete happened has no reason to look again. #7478 made it throw, naming the type and pointing at DELETE FROM <type>, which reaches the edges correctly.
Why it was not just made to work
The obvious fix - walk the vertices and delete what the walk yields - mutates the very edge lists it is iterating. GraphEngine.deleteEdge removes the entry from both endpoints' lists, so a naive walk-and-delete hits the read-modify-write hazard EdgeLinkedList.edgeIteratorForRemoval exists for (#5680), and the collect-then-delete alternative holds one entry per edge in memory - 75 million of them on the graph that opened #7477, against a TRUNCATE that is otherwise batched precisely so it does not.
So it needs the same care the removal paths in GraphEngine already have, which is more than a rider on a SELECT fix.
Shape of a fix
Either:
- Route the deletion through the removal-safe iterator, per source vertex: for each vertex, collect that one vertex's matching OUT entries, delete them, move on. Bounded by degree rather than by edge count, and reuses the invariant
edgeIteratorForRemovalalready establishes. - Or delegate to the same path
DELETE FROM <type>takes, which is already correct, and letTRUNCATEbe a thin wrapper for this case - giving up the index-drop/rebuild speed-up, which is worth nothing on a type that has no records to index anyway.
(2) is probably right: a lightweight type has no indexes to drop (it can have no properties), so the fast path truncateInOwnTransaction exists for buys nothing here.
Either way it wants tests of its own: the caller-transaction and own-transaction paths, a mixed hierarchy where only part of the type is lightweight, and rollback.
Also in this family
Database.scanType() is the shared blind spot rather than TRUNCATE specifically. Worth checking every other caller for the same silent no-op before closing this.
Activity
fix(#7477): refuse TRUNCATE TYPE on a lightweight edge type
fix: quote the rebuilt DELETE FROM type name and restore TRUNCATE's b…
fix: TRUNCATE on a LIGHTWEIGHT edge type no longer bypasses the UNSAF…
Merge pull request #7626 from ArcadeData/fix/issue-7576-7481-7480-batch
lvca commentedon Sep 15, 2026
Fixed in #7626 (26.10.1).
TRUNCATE TYPEon a LIGHTWEIGHT edge type used to always refuse, because it looked for records in a place where a lightweight edge never leaves one. It now actually deletes the edges, the same wayDELETE FROM <type>already did.One thing to know: if the type has a subtype, you now need to add
POLYMORPHICto truncate both levels together (e.g.TRUNCATE TYPE Mentions POLYMORPHIC); without it, the statement refuses rather than guessing which edges you meant.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
fix: TRUNCATE TYPE on a LIGHTWEIGHT edge type now deletes instead of …
test: cover TRUNCATE TYPE and TRAVERSE on LIGHTWEIGHT edge types (Arc…
Merge branch 'upstream-main'