@@ -30,7 +30,6 @@ type SqliteStore struct {
30
30
dbpool * sqlitex.Pool
31
31
lastIDVal atomic.Int64
32
32
dblock * flock.Flock
33
- querymu sync.RWMutex
34
33
35
34
ogidCache * lru.TwoQueueCache [opGroupInfo , int64 ]
36
35
@@ -222,8 +221,6 @@ func (m *SqliteStore) buildQueryWhereClause(q oplog.Query, includeSelectClauses
222
221
}
223
222
224
223
func (m * SqliteStore ) Query (q oplog.Query , f func (* v1.Operation ) error ) error {
225
- m .querymu .RLock ()
226
- defer m .querymu .RUnlock ()
227
224
conn , err := m .dbpool .Take (context .Background ())
228
225
if err != nil {
229
226
return fmt .Errorf ("query: %v" , err )
@@ -251,8 +248,6 @@ func (m *SqliteStore) Query(q oplog.Query, f func(*v1.Operation) error) error {
251
248
}
252
249
253
250
func (m * SqliteStore ) QueryMetadata (q oplog.Query , f func (oplog.OpMetadata ) error ) error {
254
- m .querymu .RLock ()
255
- defer m .querymu .RUnlock ()
256
251
conn , err := m .dbpool .Take (context .Background ())
257
252
if err != nil {
258
253
return fmt .Errorf ("query metadata: %v" , err )
@@ -323,16 +318,14 @@ func (m *SqliteStore) findOrCreateGroup(conn *sqlite.Conn, op *v1.Operation) (og
323
318
}
324
319
325
320
func (m * SqliteStore ) Transform (q oplog.Query , f func (* v1.Operation ) (* v1.Operation , error )) error {
326
- m .querymu .Lock ()
327
- defer m .querymu .Unlock ()
328
321
conn , err := m .dbpool .Take (context .Background ())
329
322
if err != nil {
330
323
return fmt .Errorf ("transform: %v" , err )
331
324
}
332
325
defer m .dbpool .Put (conn )
333
326
334
327
where , args := m .buildQueryWhereClause (q , true )
335
- return withSqliteTransaction (conn , func () error {
328
+ return withImmediateSqliteTransaction (conn , func () error {
336
329
return sqlitex .ExecuteTransient (conn , "SELECT operations.operation FROM operations JOIN operation_groups ON operations.ogid = operation_groups.ogid WHERE " + where , & sqlitex.ExecOptions {
337
330
Args : args ,
338
331
ResultFunc : func (stmt * sqlite.Stmt ) error {
@@ -391,15 +384,13 @@ func (m *SqliteStore) addInternal(conn *sqlite.Conn, op ...*v1.Operation) error
391
384
}
392
385
393
386
func (m * SqliteStore ) Add (op ... * v1.Operation ) error {
394
- m .querymu .Lock ()
395
- defer m .querymu .Unlock ()
396
387
conn , err := m .dbpool .Take (context .Background ())
397
388
if err != nil {
398
389
return fmt .Errorf ("add operation: %v" , err )
399
390
}
400
391
defer m .dbpool .Put (conn )
401
392
402
- return withSqliteTransaction (conn , func () error {
393
+ return withImmediateSqliteTransaction (conn , func () error {
403
394
for _ , o := range op {
404
395
o .Id = m .lastIDVal .Add (1 )
405
396
if o .FlowId == 0 {
@@ -415,15 +406,13 @@ func (m *SqliteStore) Add(op ...*v1.Operation) error {
415
406
}
416
407
417
408
func (m * SqliteStore ) Update (op ... * v1.Operation ) error {
418
- m .querymu .Lock ()
419
- defer m .querymu .Unlock ()
420
409
conn , err := m .dbpool .Take (context .Background ())
421
410
if err != nil {
422
411
return fmt .Errorf ("update operation: %v" , err )
423
412
}
424
413
defer m .dbpool .Put (conn )
425
414
426
- return withSqliteTransaction (conn , func () error {
415
+ return withImmediateSqliteTransaction (conn , func () error {
427
416
return m .updateInternal (conn , op ... )
428
417
})
429
418
}
@@ -456,8 +445,6 @@ func (m *SqliteStore) updateInternal(conn *sqlite.Conn, op ...*v1.Operation) err
456
445
}
457
446
458
447
func (m * SqliteStore ) Get (opID int64 ) (* v1.Operation , error ) {
459
- m .querymu .RLock ()
460
- defer m .querymu .RUnlock ()
461
448
conn , err := m .dbpool .Take (context .Background ())
462
449
if err != nil {
463
450
return nil , fmt .Errorf ("get operation: %v" , err )
@@ -491,16 +478,14 @@ func (m *SqliteStore) Get(opID int64) (*v1.Operation, error) {
491
478
}
492
479
493
480
func (m * SqliteStore ) Delete (opID ... int64 ) ([]* v1.Operation , error ) {
494
- m .querymu .Lock ()
495
- defer m .querymu .Unlock ()
496
481
conn , err := m .dbpool .Take (context .Background ())
497
482
if err != nil {
498
483
return nil , fmt .Errorf ("delete operation: %v" , err )
499
484
}
500
485
defer m .dbpool .Put (conn )
501
486
502
487
ops := make ([]* v1.Operation , 0 , len (opID ))
503
- return ops , withSqliteTransaction (conn , func () error {
488
+ return ops , withImmediateSqliteTransaction (conn , func () error {
504
489
// fetch all the operations we're about to delete
505
490
predicate := []string {"operations.id IN (" }
506
491
args := []any {}
@@ -548,8 +533,6 @@ func (m *SqliteStore) Delete(opID ...int64) ([]*v1.Operation, error) {
548
533
}
549
534
550
535
func (m * SqliteStore ) ResetForTest (t * testing.T ) error {
551
- m .querymu .Lock ()
552
- defer m .querymu .Unlock ()
553
536
conn , err := m .dbpool .Take (context .Background ())
554
537
if err != nil {
555
538
return fmt .Errorf ("reset for test: %v" , err )
0 commit comments