Skip to content

Fix collection creation validation, disallow replication factor 0 - #5643

Merged
timvisee merged 6 commits into
devfrom
validate-settings-startup
Dec 20, 2024
Merged

timvisee merged 6 commits into
devfrom
validate-settings-startup

Conversation

@timvisee

@timvisee timvisee commented Dec 14, 2024 •

Copy link
Copy Markdown
Member

Collection creation validation was broken, or at least parts of it. It allows creating a collection with an invalid configuration, causing crashes along the way.

We did already validate shard number, replication factor and write consistency factor fields in the REST interface, but these validations were missing in the gRPC interface. This has now been added. Along with that I've added the same validation in the collection update API. The fix works for both distributed and non-distributed mode.

We already have a misconfiguration warning on startup, but disallowing the illegal values was not enforced everywhere:

$ QDRANT__STORAGE__COLLECTION__REPLICATION_FACTOR=0 qdrant

2024-12-16T09:54:43.624658Z  WARN collection::operations::validation: Settings configuration file has validation errors:
2024-12-16T09:54:43.624828Z  WARN collection::operations::validation: - storage.collection.replication_factor: value 0 invalid, must be 1 or larger

It is possible that a collection already having illegal values configured causes errors when scaling up with a new peer. But that is easily fixed by updating the collection configuration with sounds values. I believe that's better than assuming some default.

Creating a collection over gRPC with a default shard number and replication factor of 0 now returns an error as expected:

thread 'main' panicked at src/main.rs:719:10:
called `Result::unwrap()` on an `Err` value: Error in the response: Client specified an invalid argument Validation error in body: [shard_number: value 0 invalid, must be 1 or larger; replication_factor: value 0 invalid, must be 1 or larger]

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

@timvisee
timvisee force-pushed the validate-settings-startup branch 3 times, most recently from dd09d6b to c37d7ce Compare December 16, 2024 09:50
@timvisee timvisee changed the title Validate configuration on startup, disallow replication factor 0 Fix collection creation validation, disallow replication factor 0 Dec 16, 2024
@timvisee
timvisee marked this pull request as ready for review December 16, 2024 10:11
@timvisee
timvisee force-pushed the validate-settings-startup branch from b26f317 to f0e9d3c Compare December 16, 2024 13:07
@timvisee
timvisee merged commit 2f7cde3 into dev Dec 20, 2024
@timvisee
timvisee deleted the validate-settings-startup branch December 20, 2024 11:08
timvisee added a commit that referenced this pull request Jan 8, 2025
)

* Validate default collection config in settings

* Validate shard number, replication/write consistency factor in gRPC

* Cleanup

* Add more validation rules

* Also validate strict mode config in gRPC CollectionConfig

* Update OpenAPI specification
@timvisee timvisee mentioned this pull request Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants