Feb 9, 2015

Add Domain Users as Local Sudoers (Linux, Samba, Winbind)

My first thought was to add the domain user to the wheel group:

usermod -a -G wheel corpdev\\atwlam

Though it is possible to add domain user to wheel, the user is still unable to sudo.

CORPDEV\atwlam@sles12:~> sudo su -

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

root's password:

So the second option would be to add the domain user (or group, e.g. %corpdev\\linux_admins, note the double backslashes) to sudoers:

# visudo

%wheel ALL=(ALL) NOPASSWD: ALL
%corpdev\\linux_admins ALL=(ALL) NOPASSWD: ALL

And there you go, the domain user can now use sudo:

CORPDEV\atwlam@sles12:~> sudo su -
sles12:~ #

Jan 13, 2015

Bitmap index exclusive lock on table (oracle database)

Updating table with bitmap index creates an exclusive lock on table. But only happens in the scope of the same cardinality.

E.g. insert of "Y" and "N" into a bitmap index column can happen independently, but insert "N" and "N" in different session would create a deadlock.

-- create table t
create table t (processed_flag varchar2 (1));

-- create bitmap index on tcreate bitmap index t_idx on t (processed_flag);

set pagesize 5000;
set linesize 200;
col username format a10
col owner format a10
col object_name format a20
col machine format a20

-- view locking sessions
select t2.username, t3.owner, t3.object_name, t2.machine, t2.sid as sid, t2.serial#, t2.last_call_et, t2.program, t1.locked_mode from v$locked_object t1, v$session t2, dba_objects t3 where t1.session_id = t2.sid and t1.object_id = t3.object_id order by t2.logon_time;

-- 202, 75

-- view event of waiting locked session
select sid, event from v$session_wait where sid = 202;
select sid, event from v$session_wait where sid = 75;

-- view statement of current lock session
select /* + NO_MERGE (a) NO_MERGE (b) NO_MERGE (c) */ a.username, a.machine, a.sid, a.serial#, a.last_call_et "Seconds", b.id1, c.sql_text "SQL" from v$session a, v$lock b, v$sqltext c where a.username is not null and a.lockwait = b.kaddr and c.hash_value = a.sql_hash_value;