Here's how a canal lock works going upstream:

 

Upstream

Step 1:
The barge enters the lock and the downstream gates are closed

Step 2:
The upstream sluice gates open, filling the lock and raising the barge

Step 3:
When the water reaches the level of the upstream side, the upstream lock gates open, and the barge moves on upstream