Keel hauling was reserved for the most egregious offenses. Something not done for minor infractions for which the offender was usually flogged. The mechanics were a line was passed under the ship and tied to either victims arms or legs. Another line was tied to the offenders opposite extremities. The unfortunate soul was then pulled from one side of the ship to the other. If he didn't drown in the process, would probably die later of infection from all the cuts inflicted by
Barnacles and other growth on the bottom. It was not a common capital punishment as hanging from a yard arm usually was the consequence.
Water boarding is highly over rated as a torture, btw. Every pilot who went to Viet Nam in the
Navy was water boarded as part of the SEAR
training. It's not fun but not that big a thing. Gets all the girly men's knickers in a
knot but way better than a suicide bomb.
As far as Patrick O'Brian's sailing experience, here is an interesting article from someone who took him sailing.
https://www.latitude38.com/features/O'Brian.htm