8000 potential race condition between creating and dropping collections · Issue #194 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content
potential race condition between creating and dropping collections #194
Closed
@jsteemann

Description

@jsteemann

When a collection is created, the collection is entered with its name in the hash table vocbase->_collectionsByName.
When a collection is dropped, the collection is first removed from the hash table, and then its parameter file (parameter.json) is updated with the new collection status (i.e. "deleted"). This happens in vocbase.c:TRI_DropCollectionVocBase.

The problem is that the collection is removed from the hash and the parameter file is changed at some point after that. Before the parameter file can be changed, a write-lock on the collection must be acquired. If the server must wait for the write-lock because of concurrent read operations, a concurrent thread can create a collection with the same name.
Deletion from the hash and changing the parameter file are not atomic and be interrupted by other actions.

If a concurrent thread manages to create a collection with the same name in between, this will lead to ambiguities, and if the server is stopped before the parameter file is written to disk (e.g. because it's still waiting for the write lock), the database directory will contain two collections with identical values in the "name" attributes in the parameter files, and both with the "deleted" attribute being false. The server will then fail on startup with error message "duplicate entry for name..." in vocbase.c:AddCollection.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0