Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
To facilitate:

        Multi-Object/Document Transactions,

        Differentating a read with: a bad ID vs by ID of a Deleted Document from a previous query,

        Optimistic Locking,

    All Objects/Documents should support the following fields:

        Schema Version,

        Object/Row/Document Version #,

        ActiveTransaction Reference,

        Deleted flag, &

        Deleting flag.

When initiating a change/update, if the "Deleted flag" is set then an Error Dialog should be shown.
Likewise, if the "ActiveTransaction Reference" exists, then the change/update should be delayed (with a possible) dialog.

============================================================================================================

Multi-Object/Document Transactions:

  "Commit" steps:

    1) Create a DetailedTransactionWorklist Object which contains change/rollback
       Sub-Objects for each Object in the Transaction, e.g.:

        a) Collection

        b) ID

        c) Action:

            1) Delete *1*.

            2) Insert w/ all the fields.

            3) Update (w/ sets) *1* all changed fields (grouped by Add, Delete, & Update;
               w/ Delete & Update having the original values).

            4) Adjust (w/ only numerical "adjust by" fields) all changed fields w/ "adjust by" amounts.

          *1* - These actions must also include the current Document Version # for Optimistic Lock Management.

    2) Record the DetailedTransactionWorklist to a "new" ActiveTransaction Document.
       The ActiveTransaction Document should not only contain the DetailedTransactionWorklist, but:

        a) GC-Timestamp - How far in the future? (Minutes): 2 ????????

        b) Success flag initially false / null.

    3) See "Active Transaction Rollback", If there is any failure in the following:

        a) Apply the changes from the DetailedTransactionWorklist for each Document, recording the
           success/failure into the DetailedTransactionWorklist Object.  In addition to setting the
           ActiveTransaction Reference to the ActiveTransaction ID, then based on the Action do:

            1) Delete: Set the DeletingFlag=TRUE & INC the Document Version #.

            2) Insert: Document w/ all the fields.

            3) Update: Apply the changes & INC the Document Version #.

            4) Adjust: Apply the changes & INC the Document Version #.

        b) Update the ActiveTransaction with "Success=TRUE".

        c) Update each Document in the DetailedTransactionWorklist to finish the ActiveTransaction;
           For each Action:

            1) Delete: Delete the Document by: Setting Deleted=TRUE, and clearing the rest of the Document.

            2) Insert, Update & Adjust: Clear the ActiveTransaction Reference.

    4) Delete the ActiveTransaction Document.


Active Transaction Rollback:

  Since the DetailedTransactionWorklist Object is "Up To Date" in memory, all Rollback Data & State is already
  available.

  "Active Rollback" steps:

    1) For each Successful change in the DetailedTransactionWorklist Object, do the following based on the Action:

        a) Delete: Clear the DeletingFlag!=TRUE & INC the Document Version #.

        b) Insert: Delete the Document by: Setting Deleted=TRUE, and clearing the rest of the Document.

        c) Update: Apply the "Reversing" changes & INC the Document Version #.

        d) Adjust: Apply the "Reversing" changes & INC the Document Version #.

    2) Delete the ActiveTransaction Document.


Active Transaction Garbage Collection:

  A background Thread should run every few Minutes (???? the timing) that looks for ActiveTransaction Document(s) that have their "GC-Timestamp" in the past, and process them.

  For an ActiveTransaction Document that has been marked with "Success=TRUE", then proceed w/
  ActiveTransaction "Completion":

    1) Log & Skip this ActiveTransaction Document, If there is any failure in the following:

        a) Update each Document in the DetailedTransactionWorklist to finish the ActiveTransaction;
           For each Action:

            1) Delete: Delete the Document by: Setting Deleted=TRUE, and clearing the rest of the Document.

            2) Insert, Update & Adjust: Clear the ActiveTransaction Reference.

        b) Delete the ActiveTransaction Document.

  For an ActiveTransaction Document that has NOT been marked with "Success=TRUE", then proceed w/
  ActiveTransaction "Rollback":

    1) Log & Skip this ActiveTransaction Document, If there is any failure in the following:

        a) For each change in the DetailedTransactionWorklist Object, If the Document exists AND
           the ActiveTransaction Reference refers to the current ActiveTransaction Document, then
           do the following based on the Action:

            1) Delete: If the DeletingFlag==TRUE, then clear it & the ActiveTransaction Reference, and
               INC the Document Version #.

            2) Insert: Delete the Document by: Setting Deleted=TRUE, and clearing the rest of the Document.

            3) Update: Apply the "Reversing" changes & INC the Document Version #.

            4) Adjust: Apply the "Reversing" changes & INC the Document Version #.

        b) Delete the ActiveTransaction Document.

Commits for litesoft/trunk/MongoDB.txt

Diff revisions: vs.
Revision Author Commited Message
897 Diff Diff GeorgeS picture GeorgeS Mon 25 Feb, 2013 02:04:34 +0000
896 GeorgeS picture GeorgeS Sun 24 Feb, 2013 21:02:25 +0000