diff --git a/tests/test_issues_mysqlbackend.py b/tests/test_issues_mysqlbackend.py
index 214a5c38254c864d5f3677302b8abeab3c0228e3..0ccf0ee7937ab1097051dadf8b55709d3e6fca27 100644
--- a/tests/test_issues_mysqlbackend.py
+++ b/tests/test_issues_mysqlbackend.py
@@ -25,6 +25,8 @@
 
 import caosdb as db
 
+from nose.tools import with_setup
+
 
 def setup_module():
     try:
@@ -66,3 +68,25 @@ def test_issue_18():
     C1 = db.Entity(name="C").retrieve()
     pids = [p.id for p in C1.parents]
     assert len(set(pids)) == len(pids), "Duplicate parents."
+
+
+@with_setup(setup, teardown)
+def test_issue_21():
+    """Removing the last child in an inheritance chain of 4 failed with versioning.
+
+    Tests for https://gitlab.com/caosdb/caosdb-mysqlbackend/-/issues/21
+    """
+    A = db.RecordType(name="A")
+    B = db.RecordType(name="B")
+    C = db.RecordType(name="C")
+    rec = db.RecordType(name="rec")
+
+    A.add_parent(B)
+    B.add_parent(C)
+    rec.add_parent(A)
+
+    cont = db.Container()
+    cont.extend([A, B, C, rec])
+    cont.insert()
+
+    rec.delete()