Skip to content

[CLIENT-3434] Fix the wrong client config policy used for client.batch_{operate,apply,remove,write}() when a transaction-level batch policy is passed as an argument #766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/aerospike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ Only the `hosts` key is required; the rest of the keys are optional.
* :meth:`~aerospike.Client.batch_operate` if there are only read-type operations.

Contains :ref:`aerospike_batch_policies`.

.. _config_batch_remove:

* **batch_remove** (:class:`dict`)
Default delete policy used in batch remove commands.

Expand All @@ -410,6 +413,9 @@ Only the `hosts` key is required; the rest of the keys are optional.
* Individual :class:`Remove <aerospike_helpers.batch.records.Remove>` instances passed to :meth:`~aerospike.Client.batch_write`

Contains :ref:`aerospike_batch_remove_policies`.

.. _config_batch_apply:

* **batch_apply** (:class:`dict`)
Default user defined function policy used in batch UDF apply commands.

Expand All @@ -419,13 +425,19 @@ Only the `hosts` key is required; the rest of the keys are optional.
* Individual :class:`Apply <aerospike_helpers.batch.records.Apply>` instances passed to :meth:`~aerospike.Client.batch_write`

Contains :ref:`aerospike_batch_apply_policies`.

.. _config_batch_write:

* **batch_write** (:class:`dict`)
Default batch write policy when a transaction-level :ref:`batch write policy <aerospike_batch_write_policies>` is not provided:

* Individual :class:`Write <aerospike_helpers.batch.records.Write>` instances passed to :meth:`~aerospike.Client.batch_write`
* :meth:`~aerospike.Client.batch_operate` when there is at least one write-type operation.

Contains :ref:`aerospike_batch_write_policies`.

.. _config_batch_parent_write:

* **batch_parent_write** (:class:`dict`)
Default parent batch policy used in batch write commands.

Expand Down
36 changes: 28 additions & 8 deletions doc/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ Batched Commands
The resulting status and operated bins are set in ``batch_records.results`` and ``batch_records.record``.

:param BatchRecords batch_records: A :class:`BatchRecords` object used to specify the operations to carry out.
:param dict policy_batch: aerospike batch policy :ref:`aerospike_batch_policies`.
:param dict policy_batch: Optional See :ref:`aerospike_batch_policies`. If a policy value is set in the dynamic config, it will take precedence
over the policy provided at the command level. If no batch policy is provided, the global :ref:`batch_parent_write policy <config_batch_parent_write>`
in the :ref:`Client Config <client_config>` will be used it exists; otherwise, the defaults for :ref:`batch policy <aerospike_batch_policies>`
will be applied.

:return: A reference to the batch_records argument of type :class:`BatchRecords <aerospike_helpers.batch.records>`.

Expand Down Expand Up @@ -343,8 +346,14 @@ Batched Commands

:param list keys: The keys to operate on.
:param list ops: List of operations to apply.
:param dict policy_batch: See :ref:`aerospike_batch_policies`.
:param dict policy_batch_write: See :ref:`aerospike_batch_write_policies`.
:param dict policy_batch: Optional See :ref:`aerospike_batch_policies`. If a policy value is set in the dynamic config, it will take precedence over
the policy provided at the command level. If no batch policy is provided, the global :ref:`batch_parent_write policy <config_batch_parent_write>`
in the :ref:`Client Config <client_config>` will be used it exists; otherwise, the defaults for :ref:`batch policy <aerospike_batch_policies>`
will be applied.
:param dict policy_batch_write: Optional See :ref:`aerospike_batch_write_policies`. If a policy value is set in the dynamic config, it will
take precedence over the policy provided at the command level. If no batch write policy is provided, the global
:ref:`batch_write policy <config_batch_write>` in the :ref:`Client Config <client_config>` will be used it exists; otherwise,
the defaults for :ref:`batch write policy <aerospike_batch_write_policies>` will be applied.
:param int ttl: The time-to-live (expiration) of each record in seconds.

:return: an instance of :class:`BatchRecords <aerospike_helpers.batch.records>`.
Expand All @@ -364,8 +373,14 @@ Batched Commands
:param str module: the name of the UDF module.
:param str function: the name of the UDF to apply to the record identified by *key*.
:param list args: the arguments to the UDF.
:param dict policy_batch: See :ref:`aerospike_batch_policies`.
:param dict policy_batch_apply: See :ref:`aerospike_batch_apply_policies`.
:param dict policy_batch: Optional See :ref:`aerospike_batch_policies`. If a policy value is set in the dynamic config, it will take precedence over the
policy provided at the command level. If no batch policy is provided, the global :ref:`batch_parent_write policy <config_batch_parent_write>`
in the :ref:`Client Config <client_config>` will be used it exists; otherwise, the defaults for :ref:`batch policy <aerospike_batch_policies>`
will be applied.
:param dict policy_batch_apply: Optional See :ref:`aerospike_batch_apply_policies`. If a policy value is set in the dynamic config, it will take precedence
over the policy provided at the command level. If no batch apply policy is provided, the global :ref:`batch_apply policy <config_batch_apply>`
in the :ref:`Client Config <client_config>` will be used it exists; otherwise, the defaults for
:ref:`batch apply policy <aerospike_batch_apply_policies>` will be applied.

:return: an instance of :class:`BatchRecords <aerospike_helpers.batch.records>`.
:raises: A subclass of :exc:`~aerospike.exception.AerospikeError`. See note above :meth:`batch_write` for details.
Expand All @@ -385,9 +400,14 @@ Batched Commands
Remove multiple records by key.

:param list keys: The keys to remove.
:param dict policy_batch: Optional aerospike batch policy :ref:`aerospike_batch_policies`.
:param dict policy_batch_remove: Optional aerospike batch remove policy :ref:`aerospike_batch_remove_policies`.
:return: an instance of :class:`BatchRecords <aerospike_helpers.batch.records>`.
:param dict policy_batch: Optional See :ref:`aerospike_batch_policies`. If a policy value is set in the dynamic config, it will take precedence over the
policy provided at the command level. If no batch policy is provided, the global :ref:`batch_parent_write policy <config_batch_parent_write>`
in the :ref:`Client Config <client_config>` will be used it exists; otherwise, the defaults for :ref:`batch policy <aerospike_batch_policies>`
will be applied.
:param dict policy_batch_remove: Optional See :ref:`aerospike_batch_remove_policies`. If a policy value is set in the dynamic config, it will take
precedence over the policy provided at the command level. If no batch remove policy is provided, the global
:ref:`batch_remove policy <config_batch_remove>` in the :ref:`Client Config <client_config>` will be used it exists;
otherwise, the defaults for :ref:`batch remove policy <aerospike_batch_remove_policies>` will be applied.
:raises: A subclass of :exc:`~aerospike.exception.AerospikeError`. See note above :meth:`batch_write` for details.

.. include:: examples/batch_remove.py
Expand Down
11 changes: 6 additions & 5 deletions src/main/client/batch_apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,18 @@ static PyObject *AerospikeClient_Batch_Apply_Invoke(
if (py_policy_batch) {
if (pyobject_to_policy_batch(
self, err, py_policy_batch, &policy_batch, &policy_batch_p,
&self->as->config.policies.batch, &batch_exp_list,
&self->as->config.policies.batch_parent_write, &batch_exp_list,
&batch_exp_list_p) != AEROSPIKE_OK) {
goto CLEANUP;
}
}

if (py_policy_batch_apply) {
if (pyobject_to_batch_apply_policy(
self, err, py_policy_batch_apply, &policy_batch_apply,
&policy_batch_apply_p, &batch_apply_exp_list,
&batch_apply_exp_list_p) != AEROSPIKE_OK) {
if (pyobject_to_policy_apply(self, err, py_policy_batch_apply,
&policy_batch_apply, &policy_batch_apply_p,
&self->as->config.policies.batch_apply,
&batch_apply_exp_list,
&batch_apply_exp_list_p) != AEROSPIKE_OK) {
goto CLEANUP;
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/client/batch_operate.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,17 @@ static PyObject *AerospikeClient_Batch_Operate_Invoke(
if (py_policy_batch) {
if (pyobject_to_policy_batch(
self, err, py_policy_batch, &policy_batch, &policy_batch_p,
&self->as->config.policies.batch, &batch_exp_list,
&self->as->config.policies.batch_parent_write, &batch_exp_list,
&batch_exp_list_p) != AEROSPIKE_OK) {
goto CLEANUP;
}
}

if (py_policy_batch_write) {
if (pyobject_to_batch_write_policy(
if (pyobject_to_policy_batch_write(
self, err, py_policy_batch_write, &policy_batch_write,
&policy_batch_write_p, &batch_write_exp_list,
&policy_batch_write_p, &self->as->config.policies.batch_write,
&batch_write_exp_list,
&batch_write_exp_list_p) != AEROSPIKE_OK) {
goto CLEANUP;
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/client/batch_remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,17 @@ static PyObject *AerospikeClient_Batch_Remove_Invoke(
if (py_policy_batch) {
if (pyobject_to_policy_batch(
self, err, py_policy_batch, &policy_batch, &policy_batch_p,
&self->as->config.policies.batch, &batch_exp_list,
&self->as->config.policies.batch_parent_write, &batch_exp_list,
&batch_exp_list_p) != AEROSPIKE_OK) {
goto CLEANUP;
}
}

if (py_policy_batch_remove) {
if (pyobject_to_batch_remove_policy(
if (pyobject_to_policy_remove(
self, err, py_policy_batch_remove, &policy_batch_remove,
&policy_batch_remove_p, &batch_remove_exp_list,
&policy_batch_remove_p, &self->as->config.policies.batch_remove,
&batch_remove_exp_list,
&batch_remove_exp_list_p) != AEROSPIKE_OK) {
goto CLEANUP;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/client/batch_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ static PyObject *AerospikeClient_BatchWriteInvoke(AerospikeClient *self,
}

if (py_policy != NULL) {
if (pyobject_to_policy_batch(self, err, py_policy, &batch_policy,
&batch_policy_p,
&self->as->config.policies.batch,
&exp_list, &exp_list_p) != AEROSPIKE_OK) {
if (pyobject_to_policy_batch(
self, err, py_policy, &batch_policy, &batch_policy_p,
&self->as->config.policies.batch_parent_write, &exp_list,
&exp_list_p) != AEROSPIKE_OK) {
goto CLEANUP4;
}
}
Expand Down
Loading