@@ -246,19 +246,13 @@ static void onreserve(client_t client, int argc, xid_t *argv) {
246
246
}
247
247
248
248
static xid_t get_global_xmin () {
249
- int j ;
250
249
xid_t xmin = next_gxid ;
251
250
Transaction * t ;
252
251
for (t = (Transaction * )active_transactions .next ; t != (Transaction * )& active_transactions ; t = (Transaction * )t -> elem .next ) {
253
- j = t -> snapshots_count > MAX_SNAPSHOTS_PER_TRANS ? MAX_SNAPSHOTS_PER_TRANS : t -> snapshots_count ;
254
- while (-- j >= 0 ) {
255
- Snapshot * s = transaction_snapshot (t , j );
256
- if (s -> xmin < xmin ) {
257
- xmin = s -> xmin ;
258
- }
259
- // minor TODO: Use 'times_sent' to generate a bit greater xmin?
260
- }
261
- }
252
+ if (t -> xmin < xmin ) {
253
+ xmin = t -> xmin ;
254
+ }
255
+ }
262
256
return xmin ;
263
257
}
264
258
@@ -283,7 +277,6 @@ static void onbegin(client_t client, int argc, xid_t *argv) {
283
277
free_transactions = t -> elem .next ;
284
278
}
285
279
transaction_clear (t );
286
- l2_list_link (& active_transactions , & t -> elem );
287
280
288
281
prev_gxid = t -> xid = next_gxid ++ ;
289
282
t -> snapshots_count = 0 ;
@@ -299,15 +292,15 @@ static void onbegin(client_t client, int argc, xid_t *argv) {
299
292
CLIENT_ID (client ), t -> xid
300
293
);
301
294
client_message_shortcut (client , RES_FAILED );
295
+ free_transaction (t );
302
296
return ;
303
297
}
304
-
305
298
xid_t gxmin = get_global_xmin ();
299
+ Snapshot * snap = transaction_next_snapshot (t );
300
+ gen_snapshot (snap ); // FIXME: increase 'times_sent' here? see also 4765234987
306
301
307
- gen_snapshot (transaction_next_snapshot (t ));
308
- // will wrap around if exceeded max snapshots
309
- Snapshot * snap = transaction_latest_snapshot (t );
310
- // FIXME: increase 'times_sent' here? see also 4765234987
302
+ t -> xmin = snap -> xmin ;
303
+ l2_list_link (& active_transactions , & t -> elem );
311
304
312
305
xid_t ok = RES_OK ;
313
306
client_message_start (client ); {
@@ -462,7 +455,11 @@ static void onsnapshot(client_t client, int argc, xid_t *argv) {
462
455
463
456
if (CLIENT_SNAPSENT (client ) == t -> snapshots_count ) {
464
457
// a fresh snapshot is needed
465
- gen_snapshot (transaction_next_snapshot (t ));
458
+ Snapshot * snap = transaction_next_snapshot (t );
459
+ gen_snapshot (snap );
460
+ if (snap -> xmin < t -> xmin ) {
461
+ t -> xmin = snap -> xmin ;
462
+ }
466
463
}
467
464
468
465
xid_t gxmin = get_global_xmin ();
0 commit comments