change upsert case to work around bug in shard
update utils.js for shard mode 2 support