Handling database fetch size in Sqoop

Handling database fetch size in Sqoop

When importing data from various RDBMSs you might not have found any issue in the process. This does not mean your Sqoop Import command will work perfectly all the time. When the size of fetched data is small which can fit into allocated memory you will not face any issues. But when fetched data reaches beyond the allocated memory size, you will start finding issues.  Your MapReduce job fails and throws exception “GC Overhead limit exceeded”.

Why Sqoop Import throws this exception?
The answer is – During the process, RDBMS database (NOT SQOOP) fetches all the rows at one shot and tries to load everything into memory. This causes memory spill out and throws error. To overcome this you need to tell RDBMS database to return the data in batches. The following parameters “?dontTrackOpenResources=true&defaultFetchSize=10000&useCursorFetch=true” following the jdbc connection string tells database to fetch 10000 rows per batch.

sqoop import \
  --connect jdbc:mysql://host.name.or.ip/mydb?dontTrackOpenResources=true&defaultFetchSize=10000&useCursorFetch=true \
  --username SOMEUSER -P -m 1

My issue and solution was specific to MySQL, but I suspect that the same problem could occur for other RDBMS and jdbc drivers. You might need to figure out options for others.

You can post here your solution if you were in similar situation and got it resolved for RDBMSs other than MySQL.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值