Sunday 16 March 2008

Logging SQL Commands of Selected Users in PostgreSQL

Recently looked a bit into logging PostgreSQL for one of our production setups. The reason was that we wanted to find a secure way to log the SQL commands run by ordinary users but ignore the commands run by the server users. This was for security and auditing purposes. We tried logging all SQL commands once - was enough to bring the disks to a total halt due to the traffic.

After some investigation, turns out the trick is using the ROLES settings to turn on logging for the users you are interested in. As long as the user is not a superuser, this works fine. Even with superusers, you should at least see the command that turns off logging. A snippet of the configuration:

CREATE ROLE viewer;
CREATE ROLE updater;
CREATE ROLE server;

CREATE ROLE admin CREATEDB CREATEROLE;
ALTER ROLE viewer, updater, admin SET log_statement TO 'all';

CREATE ROLE ken LOGIN INHERIT;
GRANT updater TO ken;
This means that all users with viewer, updater or admin role will have all their statements logged. Of course, you still have to set logging to a secure location.

Burnt Out Light Bulbs vs Burnt Out Managers

Encountered a great way to describe the management mindset during a weekly chat recently. Say there's a burnt out lightbulb in the office. You're from the maintenance department. What you perceive as the problem and how you go about resolving it is very different depending on whether you're normal staff or manager/team leader:

  • Staff: Problem - burnt out lightbulb. Solution - Replace bulb.
  • Manager/Team Leader: Problem - team has not replaced lightbulb. Solution - examine team and processes to improve them and ensure that all burnt out bulbs will be dealt with in a timely fashion in the future.

This highlights the major shift in thinking anytime someone begins moving up the management ranks. Too often, I've seen recently promoted team leaders/managers try to take all the burden of work onto themselves. Anytime they see something wrong, they try to fix it themselves. That is not their job and in the long run, it only burns them out. It is a short term solution that merely masks the underlying problems.

Management isn't about doing the task. It's about training, enabling and motivating your team to do the tasks. The focus is no longer on what you as a person can do but about what you can enable your team to do. You must clean out the obstacles in their way, provide missing training and organize resources so that the team functions at peak productivity.

Another example is watching a team that is struggling because of insufficient teammates. Because there aren't enough people around to do the job, the manager often rolls up his/her sleeves and jumps into the tasks, trying to add 1 more person's productivity to the team. That is fine if and only if the manager has already done everything in his/her power to increase team size. Has every avenue to expand the team been thoroughly explored? Are there no other resources the manager can beg/borrow/steal? In many cases, it is better to let team productivity suffer in the short term while management resources are devoted to building for the future.

Being a manager isn't about what you can do. It is all about what your team can do. It is a very different way of thinking.

Tuesday 12 February 2008

Slave or Free Citizen?

My attitudes towards work has changed a lot over the years. At graduation, I had the usual, "Get into big corporation and work hard" mentality. Over the years, that has changed and mellowed a lot as I have worked with and in several large and dysfunctional organizations. I have come to figure out what I wanted out of life and what type of organization would best suite my needs. I have also learned to laugh at the misconceptions that I had at graduation.

That's why articles like this annoy me. Entitled "4 Things You Should Never Say to the CEO", it gives readers the impression that they must work in fear of the single mistake that will destroy their careers and ruin their lives forever. It suggests that CEOs/bosses are like Greek gods, capricious and unpredictable. Employees, even Vice-Presidents, must tremble in fear.

In the current recession fearing climate, this article and many others like it give the impression that the employee is little more than a slave. They live in fear for their jobs, work only because they have no other choice and are at the mercy of their bosses. Unfortunately enough, too many believe this. There are too many people out there working under miserable conditions and accepting abuse that they should not. The term wage slave exists for a reason. Nothing could be further from the truth.

We are all free beings and we should act like it. In my opinion, there are a few things that distinguish a free being from a wage slave:

  • Attitude
  • Financial Independence
  • Ability

ATTITUDE

This is the most critical part of being free - you must believe that you are. No matter what you encounter, you always have a choice and you _choose_ to be where you are. No matter what, there is always another option. It might not be any more pleasant than where you currently are at, but you chose to take this option rather than one of the many alternatives

This is liberating in a few ways. Firstly, since the choice is yours to make, you are free to unmake your choice or to choose something better if things change. If your boss or co-worker is an unbearable pain, then do something about it! You have many options, including switching jobs. You are never truly trapped.

Second, by realizing that you chose this option out of many others, you keep your eyes open for other potentially better choices that come by. Too many people fail to pay attention and miss the many other better opportunities out there.

Third, since it was a choice, you know your reasons for staying in this job. You know what benefits and drawbacks of this choice as opposed to the others you could have chosen. This reminds you of the positive reasons why you are here, to balance any potentially negative reasons.

Finally, knowing that its your choice makes it your responsibility. For many, this means that instead of passively accepting, they are constantly looking for ways to improve their situation.

FINANCIAL INDEPENDENCE

Many people say that they must stay at their jobs because they feel they are dependent on the pay check. They cannot quit because the loss of income would be disastrous to them.

Financial independence is the solution to that. It's unfortunately far too large a subject to be properly covered here. However, you do not need full independence to be free. You merely need a sufficient buffer to cover you until you have secured another stream of revenue. Often a reserve cash buffer of six months salary is more than enough for this.

Building this reserve takes some effort of course but for most, it is quite achievable. It requires discipline, sacrifice and living within one's means. However, the feeling of liberation and freedom when you have achieved it is worth it. The idea that you can quit the next time someone attempts to mistreat you at your job gives an immense feeling of satisfaction and confidence.

ABILITY

Finally, being really good at what you do opens up a lot more options. Even during a recession, all the competent people I knew were in demand and able to find employment with ease. The market for good people is always tight, no matter how tough it may be for others.

Once again, volumes can be written about the need for constantly improving one's skills and ensuring they are relevant. Just do it. Keep improving and your ability to earn will increase too.

This has a side benefit of reducing your need for financial independence. The better you are, the less financial reserve you need. It is also easier for you to earn money and save it.

FINAL THOUGHTS

Everyone's starting point in life is different. Not everyone has the same array of choices and some are more fortunate than others. That said, it is still our choice and still in our power to make a difference in our lives. We do not have to take the abuse that dysfunctional organizations dish out.

This blog post started as a rant against the poor way many organizations/managers treat their people - as slaves, not as free humans. However, this condition will last for as long as we allow it. As long as enough humans accept abuse and slave-like treatment from their employers and managers, this situation will not change.

If you are unhappy with the way you are being treated, you have to demand better treatment for yourself. However, you can only do this after making sure you are in a position to make these demands. Attitude, financial independence and ability. Get to work collecting them :)