As stated in http://www.postgresql.org/docs/8.2/interactive/explicit-locking.html there will be no gaurantee Limit can be applied before the locking row. Although wrapper over pg_try_advisory_lock should work but not working.
The fallowing code is locking only one row.If same code is executed from other instance instead of locking unlocked row it is trying to lock the first id which was already locked and returning false.
ref: http://www.flyingtealeaf.com/2010/02/17/postgresql-concurrency
lock the rows until next select postgres
and this
select pg_try_advisory_lock(id), *
from
(
select id,val
from test
left JOIN pg_locks pgl
ON pgl.classid = tableoid('test')
AND pgl.objid = test.id
AND pgl.pid <> pg_backend_pid()
WHERE pgl.objid IS NULL
order by id limit 1
) t