1
00:00:00,080 --> 00:00:04,380
so you can see why this is a concurrency problem, because if I have an approval and I

2
00:00:04,380 --> 00:00:09,560
let two sales go through because they arrived concurrently or tried to happen concurrently,

3
00:00:09,700 --> 00:00:15,160
well, then I've broken my policy rules just in the back end, right? I've broken the semantics

4
00:00:15,160 --> 00:00:19,800
of the policy language and what I promised the agent was not allowed to do.

5
00:00:20,840 --> 00:00:25,500
So now I can get into database isolation, and I can say, well, what if I ran this at

6
00:00:25,500 --> 00:00:29,880
read committed? And here I'm using PostgreSQL's definition of read committed rather than

7
00:00:29,880 --> 00:00:30,120
NC's

8
00:00:32,360 --> 00:00:36,960
because PostgreSQL's definitions are much saner. Different topic for a different talk,

9
00:00:37,060 --> 00:00:41,860
I guess, but at read committed, read committed allows lost rights, and that means that

10
00:00:41,860 --> 00:00:46,700
two concurrent transactions could be writing the same row and they could both end up

11
00:00:46,700 --> 00:00:47,120
committing.

12
00:00:48,420 --> 00:00:55,020
This is not acceptable behavior, but it is widely used. And so what would happen is Agent

13
00:00:55,020 --> 00:01:00,340
A gets approval to sell. Agent A and Agent B start selling the shares in parallel, so

14
00:01:00,340 --> 00:01:02,960
we have an approval. We're trying to sell both shares.

15
00:01:04,280 --> 00:01:09,100
The reading, the state, which says there's an approval, nobody's written yet that there's

16
00:01:09,100 --> 00:01:14,620
a sale, says, okay, let's go ahead. Now they both try and commit, and at read committed,

17
00:01:14,700 --> 00:01:18,960
I'm okay with this because they're both going to write like, yep, yep, I've sold, and

18
00:01:18,960 --> 00:01:22,240
they will both go ahead and commit, and now I've sold those shares twice,

19
00:01:23,260 --> 00:01:27,700
and I don't know, maybe I'm going to go to jail or something. This is bad. I don't want

20
00:01:27,700 --> 00:01:28,040
this.
