On a reasonable big domain (~800 users), using postgres as a backend on a RHES 3 dual processor, Samba hangs after a while. This is Samba 3.0.{11,12}, compiled from source. The problem goes away using the smbpasswd backend. The symptom is that at the beginning everything works fine, but after a while (generally aprox. 1 hour), the number of smb processes start to climb from ~20 to ~100 or more, and don't die with regular kill. At this point, all domain activity stops, even though the database log shows that there are still some queries going on (maybe already stablished connections?). Samba logs do not show any error (log level 3), and neither the database. I have an lsof capture at the time of the problem, but not sure what to look up for in there.
New info, not sure if related or not: at some point, the samba logs show: [2005/03/28 13:30:07, 0] passdb/pdb_pgsql.c:pgsqlsam_select_by_field(251) Error executing SELECT logon_time,logoff_time,kickoff_time,pass_last_set_time,pass_can_change_time,pass_must_change_time,username,domain,nt_username,nt_fullname,home_dir,dir_drive,logon_script,profile_path,acct_desc,workstations,unknown_str,munged_dial,user_sid,group_sid,lm_pw,nt_pw,NULL,acct_ctrl,logon_divs,hours_len,bad_password_count,logon_count,unknown_6 FROM sso.samba WHERE username = 'XXXXXXXXXXXX', ERROR: parser: parse error at or near "WHERE" at character 22 But the corresponding entry in the postgres logs do not flag the query as error (it actually executes OK when pasted).
Correction: The postgres log doesn't show the error, because it actually corresponds to another, previous query: 2005-03-28 13:38:21 [12979] LOG: query: UPDATE sso.samba SET WHERE user_sid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX' 2005-03-28 13:38:21 [12979] ERROR: parser: parse error at or near "WHERE" at character 22 This might (just speculating here) be related to the 3.0.12 Release Notes item: * BUG 1957: Implement minimal update of fields in mySQL pdb module. But the hanging problem was first seen with 3.0.11 (when this messages didn't appear), so might not be related to this.
It seems the way Samba is handling the connection to postgres is wrong. Please take a look at my post to the postgres mailing list to check that my description is accurate: http://marc.theaimsgroup.com/?l=postgresql-general&m=111219491822790&w=2 Thanks.
Created attachment 1143 [details] Correct SQL usage in various ways Two problems were solved: -BUG 1957 correction introduced situations where Samba would issue an "UPDATE table SET WHERE user='XXX'" (notice the absence of condition). See sql_account_query_update(), which now returns NULL if no field was changed. This was also corrected for mysql, although not tested. -A single connection shared among many processes is not correct per libpq docs. So I made it connect, issue a command and disconnect. This is not optimal, although now it works correctly. I'm planning on building a connection pool version, but I'm still not familiar on the mutex mechanisms prefered by Samba. Would apreciate some advice on that. -Warning. The patch also includes BUG 2334 patch, and probably obsoletes BUG 2348 (not tested yet).
Forgot to mention: the patch is against 3.0.13.
Created attachment 1153 [details] Correct SQL usage in various ways (improved) This patch improves the previous one by using one connection per Samba process (versus one connection per query). Both the master process and each child get their own connection.
The fixes has recently been commited.
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.