Samar Mohamed
Samar Mohamed

Reputation: 71

Why am I getting a "TXN_ERROR_NOT_EXIST ERROR" in GridDB when performing a user or database administration operation?

I'm working with GridDB for managing a distributed database system and recently encountered the following error while trying to perform a user or database administration operation:

10086 TXN_ERROR_NOT_EXIST ERROR
User/DB administration operation failed. User may not exist. Check the user name.

Here is a simplified version of the code I'm using to manage user roles:

from griddb_python import StoreFactory, GSException

def create_user(username, password):
    try:
        factory = StoreFactory.get_default()
        gridstore = factory.get_store({
            "host": "239.0.0.1",
            "port": 41999,
            "cluster_name": "defaultCluster",
            "username": "admin",
            "password": "admin"
        })

        # Attempt to create a new user
        user_management = gridstore.get_user_management()
        user_management.create_user(username, password)
        print(f"User '{username}' created successfully.")

    except GSException as e:
        print(f"Operation failed: {e.what()}")
        raise

def grant_privileges(username):
    try:
        factory = StoreFactory.get_default()
        gridstore = factory.get_store({
            "host": "239.0.0.1",
            "port": 41999,
            "cluster_name": "defaultCluster",
            "username": "admin",
            "password": "admin"
        })

        # Attempt to grant privileges to the user
        user_management = gridstore.get_user_management()
        user_management.grant_role(username, "dbOwner")
        print(f"Privileges granted to user '{username}'.")

    except GSException as e:
        print(f"Operation failed: {e.what()}")
        raise

if __name__ == "__main__":
    create_user("testUser", "password123")
    grant_privileges("testUser")

In this code:

The create_user function is intended to create a new user in GridDB. The grant_privileges function grants database owner privileges to the specified user. I receive the TXN_ERROR_NOT_EXIST ERROR 10086 when trying to grant privileges to the user. This error suggests that the user may not exist, but I have already attempted to create the user in the previous step.

Here are some additional details about my setup:

Operating System: Ubuntu 20.04 Python Version: 3.8 GridDB Version: 4.5 Cluster Size: 5 nodes Database: A single default database within the cluster I'm looking for guidance on:

Possible reasons for receiving the TXN_ERROR_NOT_EXIST ERROR 10086 when the user was created in the same script. Best practices for managing user accounts and privileges in GridDB. Any additional steps I should take to ensure the user exists before performing operations. Has anyone experienced similar issues with GridDB, or can anyone provide insights into what might be going wrong?

Upvotes: 2

Views: 25

Answers (0)

Related Questions