SQLite

Check-in [69394ddaa2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix an assert() in pager.c that could fail in a concurrent transaction.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA1: 69394ddaa2bc9d26477b4359c676c598b733ac9f
User & Date: dan 2015-08-26 18:54:45.787
Context
2015-08-27
17:42
Fix a problem whereby concurrent transactions would not consider pages read by the transaction before the first write statement. (check-in: fc17f73170 user: dan tags: begin-concurrent)
2015-08-26
18:54
Fix an assert() in pager.c that could fail in a concurrent transaction. (check-in: 69394ddaa2 user: dan tags: begin-concurrent)
18:02
Fix a problem allowing some conflicting transactions to be committed. (check-in: a0566382d5 user: dan tags: begin-concurrent)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916

    case PAGER_WRITER_LOCKED:
      assert( p->eLock!=UNKNOWN_LOCK );
      assert( pPager->errCode==SQLITE_OK );
      if( !pagerUseWal(pPager) ){
        assert( p->eLock>=RESERVED_LOCK );
      }
      assert( pPager->dbSize==pPager->dbOrigSize );
      assert( pPager->dbOrigSize==pPager->dbFileSize );
      assert( pPager->dbOrigSize==pPager->dbHintSize );
      assert( pPager->setMaster==0 );
      break;

    case PAGER_WRITER_CACHEMOD:
      assert( p->eLock!=UNKNOWN_LOCK );







|







902
903
904
905
906
907
908
909
910
911
912
913
914
915
916

    case PAGER_WRITER_LOCKED:
      assert( p->eLock!=UNKNOWN_LOCK );
      assert( pPager->errCode==SQLITE_OK );
      if( !pagerUseWal(pPager) ){
        assert( p->eLock>=RESERVED_LOCK );
      }
      assert( pPager->dbSize==pPager->dbOrigSize || pPager->pAllRead );
      assert( pPager->dbOrigSize==pPager->dbFileSize );
      assert( pPager->dbOrigSize==pPager->dbHintSize );
      assert( pPager->setMaster==0 );
      break;

    case PAGER_WRITER_CACHEMOD:
      assert( p->eLock!=UNKNOWN_LOCK );
Changes to test/concurrent.test.
500
501
502
503
504
505
506





















507
508
509
        PRAGMA user_version;
      COMMIT;
      PRAGMA user_version;
      PRAGMA integrity_check;
    }
  } {1234 5678 ok}
}






















finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
        PRAGMA user_version;
      COMMIT;
      PRAGMA user_version;
      PRAGMA integrity_check;
    }
  } {1234 5678 ok}
}

do_multiclient_test tn {
  do_test 5.$tn.1 {
    sql1 {
      PRAGMA journal_mode = wal;
      CREATE TABLE tt(a INTEGER PRIMARY KEY, b);
      CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
      INSERT INTO tt VALUES(1, randomblob(400));
      BEGIN CONCURRENT;
    }
  } {wal}

  do_test 5.$tn.2 {
    sql1 { UPDATE t2 SET b=5 WHERE a=3 }
    sql2 { INSERT INTO tt VALUES(2, randomblob(6000)) }
  } {}

  do_test 5.$tn.3 {
    sql1 { COMMIT }
  } {}
}

finish_test

Changes to test/concurrent3.test.
172
173
174
175
176
177
178

179
180
181
182
183
184
185
foreach {tn nRepeat oplist} {
  - - ----------------------------
  1 100 { 1iiiiiiiiii }
  2 100 { 1i 2d }
  3 100 { 1d 2i }
  4  50 { 1d 2i 3d }
  5 500 { 1i 2i 3i 4i }

} {
  if {[string range $oplist 0 0]=="-"} {
    array unset rows
    reset_db
    create_schema2
    continue
  }







>







172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
foreach {tn nRepeat oplist} {
  - - ----------------------------
  1 100 { 1iiiiiiiiii }
  2 100 { 1i 2d }
  3 100 { 1d 2i }
  4  50 { 1d 2i 3d }
  5 500 { 1i 2i 3i 4i }
  6 500 { 1i 2d 3d 4d }
} {
  if {[string range $oplist 0 0]=="-"} {
    array unset rows
    reset_db
    create_schema2
    continue
  }
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
        set used(db$iDb) 1
        foreach char [split [string range $op 1 end] {}] {
          do_sql_op2 "db$iDb" $char
        }
      }

      foreach db $DBLIST { 
        if {$i==272 && $db=="db4"} breakpoint
        set rc [catch { $db eval COMMIT } msg]
        if {$rc} { $db eval ROLLBACK }
        incr stats($db,$rc)
      }
      set res [db eval {PRAGMA integrity_check}]
      if {$res != "ok"} { puts "after $db $rc: $res" ; after 1000000 }
    }







<







202
203
204
205
206
207
208

209
210
211
212
213
214
215
        set used(db$iDb) 1
        foreach char [split [string range $op 1 end] {}] {
          do_sql_op2 "db$iDb" $char
        }
      }

      foreach db $DBLIST { 

        set rc [catch { $db eval COMMIT } msg]
        if {$rc} { $db eval ROLLBACK }
        incr stats($db,$rc)
      }
      set res [db eval {PRAGMA integrity_check}]
      if {$res != "ok"} { puts "after $db $rc: $res" ; after 1000000 }
    }