Skip to content
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

[CLIENT-1854] Python client crashes while doing IO during server upgrade/downgrade #297

Merged
merged 27 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b49299a
establish connection while constructing client object, passthrough co…
rpandian-spike Oct 4, 2022
f8b897a
propagate excepotion in case of failure
rpandian-spike Oct 6, 2022
c517099
test cases update
rpandian-spike Oct 6, 2022
5fadef1
update test
rpandian-spike Oct 7, 2022
b697beb
test cases update
rpandian-spike Oct 10, 2022
8ce95b2
release note and test case update
rpandian-spike Oct 11, 2022
ca7cfb1
roll back and remove connect/close neg test cases which are no-op now
rpandian-spike Oct 11, 2022
7659670
release doc update
rpandian-spike Oct 14, 2022
cbf3188
test cases update
rpandian-spike Oct 14, 2022
0cead58
point master 6.2.0 c-client
rpandian-spike Oct 17, 2022
c2e6ce5
test cases update
rpandian-spike Nov 1, 2022
5427144
add conditional connect and revert back close
rpandian-spike Nov 4, 2022
014c358
test case updte for conditional connect
rpandian-spike Nov 4, 2022
dd6dcdb
Update docs
juliannguyen4 Nov 4, 2022
dd7caf3
test case fixes
rpandian-spike Nov 8, 2022
8274937
black formatter
rpandian-spike Nov 8, 2022
880d4f7
flake8 fixes
rpandian-spike Nov 8, 2022
4285514
flake8 fixes
rpandian-spike Nov 8, 2022
05b0f04
flake8 fixes
rpandian-spike Nov 8, 2022
99bb177
clangformat fixes
rpandian-spike Nov 8, 2022
e5e66ce
clangformat fixes
rpandian-spike Nov 8, 2022
1f957b4
point to latest c-client stage branch
rpandian-spike Nov 8, 2022
fa25aa0
config rollback
rpandian-spike Nov 8, 2022
65d9091
add negative client connect test cases
rpandian-spike Nov 8, 2022
59c3d1d
use https path for submodule
rpandian-spike Nov 8, 2022
ab65515
test case name update
rpandian-spike Nov 8, 2022
1eeae69
Update aerospike_helpers/operations/bitwise_operations.py
rpandian-spike Nov 8, 2022
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "aerospike-client-c"]
path = aerospike-client-c
# url = [email protected]:aerospike/aerospike-client-c.git
url = https://github.com/aerospike/aerospike-client-c.git
url = git@github.com:aerospike/aerospike-client-c.git
rpandian-spike marked this conversation as resolved.
Show resolved Hide resolved
branch = stage
116 changes: 116 additions & 0 deletions Releases.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,119 @@
# Version 7.2.0
date: 10/14/2022

## Bug Fixes

- [CLIENT-1854] - Python client crashes while doing IO during server upgrade/downgrade

## Deprecations​

- client().connect() has been deprecated and it is a no-op. Client call itself establishes the connection object.
- client().close() has been deprecated and it is a no-op. Client destroy unwinds the conection.
- If user authentication method is used, then make sure to add user/password information into config dictionary for client call to succeed

ex) config = {
'hosts': hosts,
'policies': {'auth_mode': aerospike.AUTH_INTERNAL},
}
client = aerospike.client(config)
client.connect(user, password)

the above is changed to:

config = {
'hosts': hosts,
'policies': {'auth_mode': aerospike.AUTH_INTERNAL},
'user': user,
'password': password
}
client = aerospike.client(config)
#following is no-op
client.connect(user, password)


# Version 7.1.1
date: 10/03/2022

## Bug Fixes

- [CLIENT-1784] - Potential Memory leak with Python client.

## Improvements

- [CLIENT-1830] - Add CDT CTX base64 method for using sindex-create info command.
- [CLIENT-1825] - Expose ttl as part query object attributes.

# Version 7.1.0
date: 09/09/2022

## Bug Fixes

- [CLIENT-1810] - Read policy POLICY_KEY_SEND is not respected when set at the client level.

## New Features

- [CLIENT-1799] - Support batch read operations.

## Improvements

- [CLIENT-1749] - Add 'EXISTS' return type for CDT read operations.
- [CLIENT-1801] - Support creating an secondary index on elements within a CDT using context.
- [CLIENT-1795] - Make c-client "fail_if_not_connected" option configurable.
- [CLIENT-1791] - Review and clean up Sphinx documentation.
- [CLIENT-1792] - Update build instructions.

# Version 7.0.2
date: 05/31/2022

## Bug Fixes

- [CLIENT-1742] - Fix reference count leaks in client 7.x Batch APIs.
- [CLIENT-1753] - Fix reference count leak in cdt_ctx map_key_create and list_index_create cases.
- [CLIENT-1710] - Change BatchRecords default argument from an empty list to None.

# Version 7.0.1
date: 04/18/2022

## Bug Fixes

- [CLIENT-1708] Fix 'Unable to load batch_records module' error when batch_operate, batch_apply, or batch_remove are used without importing aerospike_helpers.batch.records.

# Version 7.0.0
date: 4/06/2022

## Breaking Changes

- Old predexp support has been removed. See [Incompatible API Changes](https://developer.aerospike.com/client/python/usage/incompatible#version-700) for details.
- Remove support for deprecated Debian 8.
- IndexNotFound and IndexNotReadable errors can now trigger retries.
- Bytes blobs read from the database will now be read as bytes instead of bytearray. See [Incompatible API Changes](https://developer.aerospike.com/client/python/usage/incompatible#version-700) for details.
- Query policies max_records and records_per_second are now fields of the Query class. See [Incompatible API Changes](https://developer.aerospike.com/client/python/usage/incompatible#version-700) for details.

## Features

- [CLIENT-1651] - Provide an API to extract an expression's base-64 representation.
- [CLIENT-1655] - Support new 6.0 truncate, udf-admin, and sindex-admin privileges. This feature requires server version 6.0+.
- [CLIENT-1659] - Support batch_write, batch_apply, batch_operate, and batch_remove client methods. This feature requires server version 6.0+.
- [CLIENT-1658] - Support partition queries. This feature requires server version 6.0+.
- [CLIENT-1690] - Support get_partitions_status for Scan objects.
- [CLIENT-1693] - Add short_query query policy. This feature requires server version 6.0+.

## Improvements

- [CLIENT-1687] - Deprecate send_set_name batch policy. Batch transactions now always send set name to the server.
- [CLIENT-1681] - Drop predexp support.
- [CLIENT-1683] - Add max retries exceeded exception.
- [CLIENT-1691] - Document partition scan functionality.
- [CLIENT-1692] - Update C client to 6.0.
- [CLIENT-1657] - Move Python client CI tests to github actions.
- [CLIENT-1694] - Make query policies max_records and records_per_second Query fields instead.
- [CLIENT-1675] - Bytes blobs read from the database will now be read as bytes instead of bytearray.
- [CLIENT-1634] - Remove support for deprecated Debian 8.

## Updates

- [Aerospike C Client 6.0.0.](/download/client/c/notes.html#6.0.0)

# Version 6.1.2

## Fixes
Expand Down
2 changes: 1 addition & 1 deletion aerospike-client-c
Submodule aerospike-client-c updated 41 files
+1 −0 .build.yml
+13 −13 Makefile
+30 −72 examples/project/Makefile
+2 −2 examples/utils/src/include/example_utils.h
+1 −1 modules/common
+1 −1 modules/mod-lua
+7 −27 project/test.mk
+2 −2 src/include/aerospike/as_async_proto.h
+4 −2 src/include/aerospike/as_cluster.h
+3 −3 src/include/aerospike/as_event.h
+6 −44 src/include/aerospike/as_node.h
+4 −10 src/include/aerospike/as_partition_filter.h
+1 −3 src/include/aerospike/as_partition_tracker.h
+3 −3 src/include/aerospike/as_pipe.h
+3 −3 src/include/aerospike/as_tls.h
+2 −2 src/include/aerospike/as_udf.h
+1 −1 src/main/aerospike/aerospike_batch.c
+2 −9 src/main/aerospike/aerospike_query.c
+4 −2 src/main/aerospike/as_cluster.c
+4 −5 src/main/aerospike/as_event.c
+1 −1 src/main/aerospike/as_event_ev.c
+1 −1 src/main/aerospike/as_event_event.c
+2 −2 src/main/aerospike/as_event_uv.c
+14 −16 src/main/aerospike/as_node.c
+27 −19 src/main/aerospike/as_partition.c
+5 −33 src/main/aerospike/as_partition_tracker.c
+1 −2 src/main/aerospike/as_pipe.c
+0 −1 src/main/aerospike/as_query_validate.c
+41 −60 src/main/aerospike/as_shm_cluster.c
+37 −36 src/main/aerospike/as_tls.c
+2 −2 src/test/aerospike_list/list_basics.c
+3 −3 src/test/aerospike_query/query_async.c
+2 −2 src/test/aerospike_query/query_foreach.c
+2 −2 src/test/util/map_rec.h
+2 −2 src/test/util/test_aerospike.h
+3 −0 vs/aerospike/aerospike.vcxproj
+9 −0 vs/aerospike/aerospike.vcxproj.filters
+12 −47 xcode/aerospike-test.xcodeproj/project.pbxproj
+8 −25 xcode/aerospike.xcodeproj/project.pbxproj
+0 −8 xcode/client.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
+42 −132 xcode/examples.xcodeproj/project.pbxproj
2 changes: 1 addition & 1 deletion aerospike_helpers/operations/bitwise_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
from aerospike import exception as e
from aerospike_helpers.operations import bitwise_operations

config = {'hosts': [('127.0.0.1', 3000)]}
config = self.connection_config.copy()
rpandian-spike marked this conversation as resolved.
Show resolved Hide resolved
client = aerospike.client(config).connect()

key = ('test', 'demo', 'bit_example')
Expand Down
7 changes: 5 additions & 2 deletions doc/aerospike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ Client

.. py:function:: client(config)

Creates a new instance of the :class:`Client` class.
Creates a new instance of the :class:`Client` class and immediately connects to the cluster.

This client can connect to the cluster and perform operations on the database.
See :ref:`client` for more details.

Internally, this is a wrapper function which calls the constructor for the :class:`Client` class.
Expand Down Expand Up @@ -360,6 +359,10 @@ Only the `hosts` key is required; the rest of the keys are optional.
If ``tls-name`` is specified, it must match the tls-name specified in the node's \
server configuration file, as well as the server's CA certificate.

* **user** (:class:`str`)
(Optional) A defined user with roles in the cluster. See :meth:`admin_create_user`.
* **password** (:class:`str`)
(Optional) The password will be hashed by the client using bcrypt.
* **lua** (:class:`dict`)
(Optional) Contains the paths to two types of Lua modules

Expand Down
4 changes: 3 additions & 1 deletion doc/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Connection

.. method:: connect([username, password])

Connect to the cluster. The optional *username* and *password* only
If there is currently no connection to the cluster, connect to it. The optional *username* and *password* only
apply when connecting to the Enterprise Edition of Aerospike.

:param str username: a defined user with roles in the cluster. See :meth:`admin_create_user`.
Expand Down Expand Up @@ -86,6 +86,8 @@ Connection
Close all connections to the cluster. It is recommended to explicitly \
call this method when the program is done communicating with the cluster.

You may call :meth:`~aerospike.Client.connect` again after closing the connection.

Record Operations
-----------------

Expand Down
2 changes: 2 additions & 0 deletions src/include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ AerospikeClient *AerospikeClient_New(PyObject *self, PyObject *args,
/**
* Connect to the database.
*/
PyObject *AerospikeClientConnect(AerospikeClient *self);
juliannguyen4 marked this conversation as resolved.
Show resolved Hide resolved

PyObject *AerospikeClient_Connect(AerospikeClient *self, PyObject *args,
PyObject *kwds);

Expand Down
1 change: 1 addition & 0 deletions src/main/client/batch_get_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static bool batch_read_operate_cb(const as_batch_read *results, uint32_t n,

r = (as_batch_read *)&results[i];
py_key = PyList_GetItem(data->py_keys, i);
// key_to_pyobject(&err, &r->key, &py_key);
rec = &r->record;

as_error_init(&err);
Expand Down
62 changes: 43 additions & 19 deletions src/main/client/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,18 @@
* Establishes a connection to the Aerospike DB instance.
*
* @param self AerospikeClient object
* @param args The args is a tuple object containing an argument
* list passed from Python to a C function
* @param kwds Dictionary of keywords
*
* Returns an instance of aerospike.Client, Which can be used later to do usual
* database operations.
* In case of error,appropriate exceptions will be raised.
*******************************************************************************************************
*/
PyObject *AerospikeClient_Connect(AerospikeClient *self, PyObject *args,
PyObject *kwds)
PyObject *AerospikeClientConnect(AerospikeClient *self)
{
as_error err;
as_error_init(&err);
char *alias_to_search = NULL;
bool free_alias_to_search = false;
PyObject *py_username = NULL;
PyObject *py_password = NULL;

if (PyArg_ParseTuple(args, "|OO:connect", &py_username, &py_password) ==
false) {
return NULL;
}

if (py_username && PyString_Check(py_username) && py_password &&
PyString_Check(py_password)) {
char *username = PyString_AsString(py_username);
char *password = PyString_AsString(py_password);
as_config_set_user(&self->as->config, username, password);
}

if (!self || !self->as || !self->as->config.hosts ||
!self->as->config.hosts->size) {
Expand Down Expand Up @@ -168,6 +150,48 @@ PyObject *AerospikeClient_Connect(AerospikeClient *self, PyObject *args,
return (PyObject *)self;
}

/**
*******************************************************************************************************
* Establishes a connection to the Aerospike DB instance.
*
* @param self AerospikeClient object
* @param args The args is a tuple object containing an argument
* list passed from Python to a C function
* @param kwds Dictionary of keywords
*
* Returns an instance of aerospike.Client, Which can be used later to do usual
* database operations.
* In case of error,appropriate exceptions will be raised.
*******************************************************************************************************
*/
PyObject *AerospikeClient_Connect(AerospikeClient *self, PyObject *args,
PyObject *kwds)
{
as_error err;
as_error_init(&err);
PyObject *py_username = NULL;
PyObject *py_password = NULL;

if (self->as && aerospike_cluster_is_connected(self->as)) {
Py_INCREF(self);
return (PyObject *)self;
}

if (PyArg_ParseTuple(args, "|OO:connect", &py_username, &py_password) ==
false) {
return NULL;
}

if (py_username && PyString_Check(py_username) && py_password &&
PyString_Check(py_password)) {
char *username = PyString_AsString(py_username);
char *password = PyString_AsString(py_password);
as_config_set_user(&self->as->config, username, password);
}

return AerospikeClientConnect(self);
}

/**
*******************************************************************************************************
* Tests the connection to the Aerospike DB
Expand Down
15 changes: 13 additions & 2 deletions src/main/client/type.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,21 @@ static int AerospikeClient_Type_Init(AerospikeClient *self, PyObject *args,
PyObject_IsTrue(py_fail_if_not_connected);
}

PyObject *py_user_name = PyDict_GetItemString(py_config, "user");
PyObject *py_user_pwd = PyDict_GetItemString(py_config, "password");
if (py_user_name && PyString_Check(py_user_name) && py_user_pwd &&
PyString_Check(py_user_pwd)) {
char *username = PyString_AsString(py_user_name);
char *password = PyString_AsString(py_user_pwd);
as_config_set_user(&config, username, password);
}

self->as = aerospike_new(&config);

if (AerospikeClientConnect(self) == NULL) {
return -1;
}

return 0;

CONSTRUCTOR_ERROR:
Expand Down Expand Up @@ -1660,8 +1673,6 @@ AerospikeClient *AerospikeClient_New(PyObject *parent, PyObject *args,
switch (return_code) {
// 0 Is success
case 0: {
// Initialize connection flag
self->is_conn_16 = false;
return self;
}
case -1: {
Expand Down
2 changes: 1 addition & 1 deletion test/config.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[community-edition]
hosts : 127.0.0.1:3000
hosts: 127.0.0.1:3000

[enterprise-edition]
hosts :
Expand Down
Loading