Skip to content

Commit dc8e93e

Browse files
authored
Merge pull request #2050 from LijuanTang94/fix/remove-deprecated-async-enabled
feat: deprecate `async_enabled` replication argument removed server-side
2 parents d9b2aaa + 8c5e783 commit dc8e93e

5 files changed

Lines changed: 77 additions & 10 deletions

File tree

integration/test_collection_config.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,9 +1706,14 @@ def test_replication_config_with_async_config(collection_factory: CollectionFact
17061706
assert ac.alive_nodes_checking_frequency is None
17071707

17081708

1709-
def test_replication_config_remove_async_config_by_disabling_async_replication(
1709+
def test_replication_config_async_config_preserved_when_disabling_async_replication(
17101710
collection_factory: CollectionFactory,
17111711
) -> None:
1712+
"""Disabling `async_enabled` must leave the collection's async replication tuning intact.
1713+
1714+
`config.update()` is a read-modify-write PUT of the whole collection, so dropping `asyncConfig`
1715+
from the merged payload would silently reset the tuning to server defaults.
1716+
"""
17121717
collection_dummy = collection_factory("dummy")
17131718
if collection_dummy._connection._weaviate_version.is_lower_than(1, 34, 18):
17141719
pytest.skip("async replication config requires Weaviate >= 1.34.18")
@@ -1733,8 +1738,14 @@ def test_replication_config_remove_async_config_by_disabling_async_replication(
17331738
),
17341739
)
17351740
config = collection.config.get()
1741+
# False on both sides of the v1.38 compatibility shim: older servers store the
1742+
# `asyncEnabled` we just sent, newer ones derive it as `factor > 1 and not globally
1743+
# disabled` — and this collection has factor=1.
17361744
assert config.replication_config.async_enabled is False
1737-
assert config.replication_config.async_config is None
1745+
ac = config.replication_config.async_config
1746+
assert ac is not None
1747+
assert ac.propagation_concurrency == 4
1748+
assert ac.hashtree_height == 20
17381749

17391750

17401751
def test_replication_config_remove_async_config(collection_factory: CollectionFactory) -> None:

test/collection/test_config.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,6 +3308,36 @@ def test_replication_config_update_merge_with_missing_async_config() -> None:
33083308
assert result["factor"] == 3
33093309

33103310

3311+
@pytest.mark.parametrize(
3312+
"config_factory",
3313+
[Configure.replication, Reconfigure.replication],
3314+
)
3315+
@pytest.mark.parametrize("async_enabled", [True, False])
3316+
def test_replication_async_enabled_emits_deprecation_warning(
3317+
config_factory: object, async_enabled: bool
3318+
) -> None:
3319+
"""`async_enabled` was removed from the server schema in v1.38 and must warn when passed.
3320+
3321+
Both booleans are covered: `False` was the explicit opt-out, so a future truthiness
3322+
check must not silently stop warning for it.
3323+
"""
3324+
with pytest.warns(DeprecationWarning, match="Dep030"):
3325+
config_factory(async_enabled=async_enabled) # type: ignore[operator]
3326+
3327+
3328+
@pytest.mark.parametrize(
3329+
"config_factory",
3330+
[Configure.replication, Reconfigure.replication],
3331+
)
3332+
def test_replication_without_async_enabled_does_not_warn(config_factory: object) -> None:
3333+
"""Omitting `async_enabled` must not emit the deprecation warning."""
3334+
import warnings
3335+
3336+
with warnings.catch_warnings():
3337+
warnings.simplefilter("error", DeprecationWarning)
3338+
config_factory(factor=3) # type: ignore[operator]
3339+
3340+
33113341
def test_nested_property_with_id_name_is_allowed() -> None:
33123342
"""A nested property named 'id' must not raise — only top-level 'id' is reserved."""
33133343
prop = Property(

test/collection/test_config_update.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def test_replication_async_config_replace_on_update() -> None:
122122
assert "hashtreeHeight" not in result["asyncConfig"]
123123

124124

125-
def test_replication_async_config_cleared_when_async_disabled() -> None:
126-
"""Test asyncConfig is removed from schema when asyncEnabled is set to False."""
125+
def test_replication_async_config_preserved_when_async_disabled() -> None:
126+
"""Test asyncConfig is preserved when asyncEnabled is set to False."""
127127
schema = {
128128
"factor": 1,
129129
"asyncEnabled": True,
@@ -132,7 +132,7 @@ def test_replication_async_config_cleared_when_async_disabled() -> None:
132132
update = Reconfigure.replication(async_enabled=False)
133133
result = update.merge_with_existing(schema)
134134
assert result["asyncEnabled"] is False
135-
assert "asyncConfig" not in result
135+
assert result["asyncConfig"] == {"maxWorkers": 8, "hashtreeHeight": 20}
136136

137137

138138
def test_replication_async_config_preserved_when_not_provided() -> None:

weaviate/collections/classes/config.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ def merge_with_existing(self, schema: Dict[str, Any]) -> Dict[str, Any]:
353353
schema["factor"] = self.factor
354354
if self.asyncEnabled is not None:
355355
schema["asyncEnabled"] = self.asyncEnabled
356-
if not self.asyncEnabled:
357-
schema.pop("asyncConfig", None)
358356
if self.deletionStrategy is not None:
359357
schema["deletionStrategy"] = str(self.deletionStrategy.value)
360358
if self.asyncConfig is not None:
@@ -2922,14 +2920,21 @@ def replication(
29222920
) -> _ReplicationConfigCreate:
29232921
"""Create a `ReplicationConfigCreate` object to be used when defining the replication configuration of Weaviate.
29242922
2925-
NOTE: `async_enabled` is only available with WeaviateDB `>=v1.26.0`
2923+
Note:
2924+
`async_enabled` is deprecated. On servers `>=v1.38` the `asyncEnabled` field no longer
2925+
exists in the schema: it is silently dropped, and async replication is decided
2926+
server-side (on by default for any collection with a replication factor > 1, unless the
2927+
`ASYNC_REPLICATION_DISABLED` runtime override is set). On older servers it still takes
2928+
effect. Passing it emits a ``DeprecationWarning``; it will be removed in a future release.
29262929
29272930
Args:
29282931
factor: The replication factor.
29292932
async_enabled: Enabled async replication.
29302933
deletion_strategy: How conflicts between different nodes about deleted objects are resolved.
2931-
async_config: The configuration for async replication. This is only relevant if `async_enabled` is `True`.
2934+
async_config: The configuration for async replication.
29322935
"""
2936+
if async_enabled is not None:
2937+
_Warnings.async_enabled_field_removed_server_side()
29332938
return _ReplicationConfigCreate(
29342939
factor=factor,
29352940
asyncEnabled=async_enabled,
@@ -3210,12 +3215,21 @@ def replication(
32103215
32113216
Use this method when defining the `replication_config` argument in `collection.update()`.
32123217
3218+
Note:
3219+
`async_enabled` is deprecated. On servers `>=v1.38` the `asyncEnabled` field no longer
3220+
exists in the schema: it is silently dropped, and async replication is decided
3221+
server-side (on by default for any collection with a replication factor > 1, unless the
3222+
`ASYNC_REPLICATION_DISABLED` runtime override is set). On older servers it still takes
3223+
effect. Passing it emits a ``DeprecationWarning``; it will be removed in a future release.
3224+
32133225
Args:
32143226
factor: The replication factor.
32153227
async_enabled: Enable async replication.
32163228
deletion_strategy: How conflicts between different nodes about deleted objects are resolved.
3217-
async_config: The async replication configuration. This is only applicable if `async_enabled` is set to `True`.
3229+
async_config: The async replication configuration.
32183230
"""
3231+
if async_enabled is not None:
3232+
_Warnings.async_enabled_field_removed_server_side()
32193233
return _ReplicationConfigUpdate(
32203234
factor=factor,
32213235
asyncEnabled=async_enabled,

weaviate/warnings.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,18 @@ def async_replication_field_removed_server_side(argument: str) -> None:
261261
stacklevel=1,
262262
)
263263

264+
@staticmethod
265+
def async_enabled_field_removed_server_side() -> None:
266+
warnings.warn(
267+
message="""Dep030: The `async_enabled` argument in `Configure.replication` / `Reconfigure.replication` is deprecated.
268+
On Weaviate v1.38 and newer the `asyncEnabled` field no longer exists in the server schema: it is silently dropped,
269+
and whether async replication runs is decided server-side, on by default for any collection with a replication
270+
factor > 1 unless the `ASYNC_REPLICATION_DISABLED` runtime override is set.
271+
On older servers the argument still takes effect, but it is deprecated and will be removed in a future release.""",
272+
category=DeprecationWarning,
273+
stacklevel=1,
274+
)
275+
264276
@staticmethod
265277
def datetime_insertion_with_no_specified_timezone(date: datetime) -> None:
266278
warnings.warn(

0 commit comments

Comments
 (0)