Found the root reason.
It is because of the nested distinct operation relies on the RAM to calculate unique values.
As described here:

Date: 2014-04-16 11:58
To: user; th; german.fl; user
Subject: Re: Re: java.lang.OutOfMemoryError related with number of reducer?
Hi German & Thomas,

    Seems i found the data that causes the error, but i still don't know the exactly reason.

    I just do a group with pig latin:
domain_device_group = GROUP data_filter BY (custid, domain, level, device);
domain_device = FOREACH domain_device_group {
distinct_ip = DISTINCT data_filter.ip;
        distinct_userid = DISTINCT data_filter.userid;
        GENERATE group.custid, group.domain, group.level, group.device, COUNT_STAR(data_filter), COUNT_STAR(distinct_ip), COUNT_STAR(distinct_userid);
STORE domain_device INTO '$outputdir/$batchdate/data/domain_device' USING PigStorage('\t');

The group key (custid, domain, level, device)  is significantly skewed,  about 42% (58,621,533 / 138,455,355) of the records are the same key, and only the reducer which handle this key failed.
But from ,  I still have no idea why it cause an OOM.  It doesn't tell how skewed key will be handled, neither how different keys in same reducer will be merged.
Date: 2014-04-15 23:35
To: user; th; german.fl
Subject: Re: RE: memoryjava.lang.OutOfMemoryError related with number of reducer?
Thanks, let me take a careful look at it.

From: German Florez-Larrahondo
Date: 2014-04-15 23:27
To: user; 'th'
Subject: RE: Re: memoryjava.lang.OutOfMemoryError related with number of reducer?
A good explanation of this can be found on the Hadoop The Definitive Guide by Tom White.
Here is an excerpt that explains a bit the behavior at the reduce side and some possible tweaks to control it.
Sent: Tuesday, April 15, 2014 9:29 AM
To: user; th
Subject: Re: Re: memoryjava.lang.OutOfMemoryError related with number of reducer?
Thanks Thomas.
Anohter question.  I have no idea what is "Failed to merge in memory".  Does the 'merge' is the shuffle phase in reducer side?  Why it is in memory?
Except the two methods(increase reducer number and increase heap size),  is there any other alternatives to fix this issue?
Thanks a lot.
From: Thomas Bentsen
Date: 2014-04-15 21:53
To: user
Subject: Re: memoryjava.lang.OutOfMemoryError related with number of reducer?
When you increase the number of reducers they each have less to work
with provided the data is distributed evenly between them - in this case
about one third of the original work.
It is eessentially the same thing as increasing the heap size - it's
just distributed between more reducers.
On Tue, 2014-04-15 at 20:41 +0800, [EMAIL PROTECTED] wrote:

NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB