jsenzier-oxeva opened a new issue, #5497:
URL: https://github.com/apache/couchdb/issues/5497

   Hi, I need to open an issue to understand what is going wrong during a user 
/ database creation on my couchdb cluster
   
   ## Description
   
   I have an issue on a production cluster (version 3.3.3) of 3 nodes (with 
per_user activated) deployed on a Kubernetes Cluster
   
   We have ~ 19000 users databases :
   
   
![Image](https://github.com/user-attachments/assets/181d5032-2e6d-4f6d-94fe-ad749961d91e)
   
   Sometimes we have this error which appears during the user creation, I got 
this error :
   
   
![Image](https://github.com/user-attachments/assets/e7b5f65b-8fc7-4759-b0a1-5fda5558c2e9)
   
   ## Steps to Reproduce
   We are using this repository :
   
   `- name: couchdb
     url: https://apache.github.io/couchdb-helm/`
   
   Here's my couchdb YAML configuration : 
https://gist.github.com/jsenzier-oxeva/d286c892e41a76be8846f4945a5dd272
   
   The encountered error is in previous Description section
   And the php code which is executed : 
https://gist.github.com/jsenzier-oxeva/dc9a05cca44ac2610b743cb97b9bb69e
   
   The error appears during this code execution :
   
   `        // create user & db
           try {
               $couchDbUserCreationResponse = $adm->createUser($userName, 
$token);
           } catch (\Exception $e) {
               Log::error("[init-user] Could not create user", ['message' => 
$e->getMessage()]);
   
               if (isset($lock) && isset($lockKey)) {
                   $lock->release($lockKey);
               }
   
               return response('server error', 500);
           }
   
           try {
               $userDoc = $userClient->getDoc($couchDbUserCreationResponse->id);
               $userDoc->email = $email;
               $userDoc->workflow_type = $workflowType;
               $userDoc->workflow_version = $templateVersion;
               $userDoc->created_at = $body['created_at'];
               $userClient->storeDoc($userDoc);
           } catch (\Exception $e) {
               Log::error("[init-user] Could save user email", ['message' => 
$e->getMessage()]);
   
               try {
                   $adm->deleteUser($userName);
               } catch (\Exception $e) {
                   Log::error("[init-user] Could not delete user after failed 
creation", ['username' => $userName, 'message' => $e->getMessage()]);
               }
   
               if (isset($lock) && isset($lockKey)) {
                   $lock->release($lockKey);
               }
   
               return response('server error', 500);
           }
   
           **$client = new CouchClient(config('couchdb.dbAdminUrl'), $dbName);
           try {
               $repeat = 5;
               while (!$client->databaseExists() && $repeat > 0) {
                   sleep(2);
                   $repeat--;
               }
   
               if (!$client->databaseExists()) {
                   $subject = 'Erreur /init-user Env : ' . env('APP_ENV') . ' ' 
. env('APP_NAME') . '';
                   $message = 'Erreur de création de base pour ' . $email . '' 
. "\r\n";
                   $message .= 'Base concernée : ' . $dbName . '';**
                   try {
                       User\deleteUserDatas($userName, false);
                   } catch (\Exception $e) {
                       $message .= "Une erreur a eu lieu lors de la suppression 
de l'utilisateur";
                   }
                   SendInBlue\sendApiErrorsMail($subject, $message);
                   Log::error(
                       "[init-user] Could not create user database",
                       ['message' => $message]
                   );
   
                   if (isset($lock) && isset($lockKey)) {
                       $lock->release($lockKey);
                   }
   
                   return response('server error', 500);
               }`
   
   User is created, then we execute a loop 5 times with a sleep 2 to wait 
database creation, but it never happens as we encountered the "security" error
   As discussed on Slack (thanks for your help) : it appears the security 
object is not identical across all shards of your database
   
   But I'm asking why and how can I resolve those errors ?
   
   ## Expected Behaviour
   
   Not having 500 error, so have a user and database creation working without 
any error in couchdb logs
   
   * CouchDB version used: 3.3.3
   * Operating system and version: Kubernetes 1.28.15 with CouchDB deployment 
(chart version 4.6.0) from official repository : 
https://apache.github.io/couchdb-helm/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to