Results of Lazy Loading with different scenarios
We can say that for every scenario the bug data was fetched just after time1.
It may be useful to consider whether the userLogged or status objects could
be considered to be "Read Consistent" with respect to the bug(at time1).
In understanding this you should be able to decide when to use lazy loading and
the potential for "Read Inconsistent" results.
|
loggedBy |
statusTitle |
Scenario 1 |
Name at time 2 |
Title @time 4 |
Scenario 2 |
Name at time 1 |
Title @time 4 |
Scenario 3 |
Name at time 1 |
Title @time 1 |
Scenario 4 |
Name at time 1 |
Title @time 1 |
Log for Scenario 1
The loggedUser is lazy loaded and because we are in a READ_COMMITED Isolation level
it does see the Update at time2. The status title is lazy loaded in its own
transaction just after time4.
Neither loggedBy nor statusTitle could be considered "Read Consistent" wrt Bug.
It didn't matter that loggedBy was fetched in the same transaction, it can still
potentially be not "Read Consistent" wrt Bug.
Update set UserName[Name at time 5] statusTitle[Title @time 5] at time [5]
INFO: DataSourcePool [ora10] grow pool; busy[1] size[1] max[25]
Update set UserName[Name at time 1] statusTitle[Title @time 1] at time [1]
<sql summary='[app.data.Bug]'>
SELECT b.id, b.body, b.cretime, b.duplicate_of, b.fixed_version,...
FROM b_bug b
WHERE b.id = ?
</sql>
Update set UserName[Name at time 2] statusTitle[Title @time 2] at time [2]
<sql summary='[app.data.User]'>
SELECT u.id, u.cookie_login, u.cretime, u.email, u.error_count,...
FROM s_user u
WHERE u.id = ?
</sql>
Update set UserName[Name at time 3] statusTitle[Title @time 3] at time [3]
Update set UserName[Name at time 4] statusTitle[Title @time 4] at time [4]
<sql summary='[app.data.BugStatus]'>
SELECT s.code, s.title
FROM b_bug_status s
WHERE s.code = ?
</sql>
-------------------------
loggedBy: [Name at time 2]
statusTitle: [Title @time 4]
Log for Scenario 2
Its the same as Scenario 1 except that the loggedBy value is [Name at time 1] due
to the transaction isolation level and the fact that the transaction started with
the first query which occured just after time1.
loggedBy could be considered "Read Consistent" wrt Bug but statusTitle could not be.
Log for Scenario 3 & 4
The user logged and bug status are included in the fetch. The fetch occurs
just after time1 and No lazy loading occurs. The transaction isolation level
doesn't matter. Results the same.
Update set UserName[Name at time 5] statusTitle[Title @time 5] at time [5]
INFO: DataSourcePool [ora10] grow pool; busy[1] size[1] max[25]
Update set UserName[Name at time 1] statusTitle[Title @time 1] at time [1]
<sql summary='[app.data.Bug, status, userLogged]'>
SELECT b.id, b.body, b.cretime, b.duplicate_of, b.fixed_version,...
, ss.code, ss.title, b.type_code, b.user_assigned_id
, au.id, au.cookie_login, au.cretime, au.email, au.error_count,...
FROM b_bug b
JOIN b_bug_status ss ON b.status_code = ss.code
LEFT OUTER JOIN s_user au ON b.user_logged_id = au.id
WHERE b.id = ?
</sql>
Update set UserName[Name at time 2] statusTitle[Title @time 2] at time [2]
Update set UserName[Name at time 3] statusTitle[Title @time 3] at time [3]
Update set UserName[Name at time 4] statusTitle[Title @time 4] at time [4]
-------------------------
loggedBy: [Name at time 1]
statusTitle: [Title @time 1]
|