Request timeout when creating a custom field with default value for millions of objects
type: bugstatus: needs ownerseverity: mediumnetbox
### NetBox Edition
NetBox Community
### NetBox Version
v4.6.8
### Python Version
3.14
### Steps to Reproduce
1. Start with a database with e.g. 10 million interfaces.
2. Create a new custom field (of any type) for interfaces, with a default value.
### Expected Behavior
The new custom field should be created almost immediately, similar to creating a custom field with no default value.
### Observed Behavior
Because the new custom field specifies a default value, all objects to which it applies are updated synchronously (via batched `jsonb_set()` calls) to apply the specified value. Where many millions of applicable objects exist, this operation can exceed the configured request timeout. If the timeout is exceeded, the request is aborted and the creation of the new custom field fails.
One potential solution is to defer the population of the initial value to an asynchronous background task, although that introduces a race condition. Further exploration is needed.
As a workaround, users finding themselves in this predicament can create custom fields with no default value initially, then perform a round of bulk updates to set the value on all applicable objects, and finally update the custom field to set the default value.
0 条评论