/ Check-in [fbfa5471]
Login
Overview
Comment:Include the value of the "flags" byte of the relevant page in the log message emitted when a BEGIN CONCURRENT commit conflict is detected.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256:fbfa547177ac7d57dcb0775d761a7f92fc1f2263cd83e2843cd109139a8c5121
User & Date: dan 2018-05-15 08:51:05
Context
2018-05-15
11:28
Instead of just the flags byte, include the first 8 bytes of the relevant page in an on-commit conflict log message. check-in: e7dc03e7 user: dan tags: begin-concurrent
09:03
Include the value of the "flags" byte of the relevant page in the log message emitted when a BEGIN CONCURRENT commit conflict is detected. check-in: de19abb9 user: dan tags: begin-concurrent-pnu
08:51
Include the value of the "flags" byte of the relevant page in the log message emitted when a BEGIN CONCURRENT commit conflict is detected. check-in: fbfa5471 user: dan tags: begin-concurrent
2018-04-26
17:54
Merge latest changes from trunk. Including the "ORDER BY ... LIMIT" optimization. check-in: d8ae7ba0 user: dan tags: begin-concurrent
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/btree.c.

10429
10430
10431
10432
10433
10434
10435

10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446

10447
10448
10449
10450
10451
10452
10453
.....
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476

10477
10478
10479
10480
10481
10482
10483
#ifdef SQLITE_OMIT_CONCURRENT
  assert( pgno==0 );
#else
  if( rc==SQLITE_BUSY_SNAPSHOT && pgno ){
    PgHdr *pPg = 0;
    int rc2 = sqlite3PagerGet(pBt->pPager, pgno, &pPg, 0);
    if( rc2==SQLITE_OK ){

      int bWrite = -1;
      const char *zObj = 0;
      const char *zTab = 0;

      if( pPg ){
        Pgno pgnoRoot = 0;
        HashElem *pE;
        Schema *pSchema;

        pgnoRoot = ((MemPage*)sqlite3PagerGetExtra(pPg))->pgnoRoot;
        bWrite = sqlite3PagerIswriteable(pPg);

        sqlite3PagerUnref(pPg);

        pSchema = sqlite3SchemaGet(p->db, p);
        if( pSchema ){
          for(pE=sqliteHashFirst(&pSchema->tblHash); pE; pE=sqliteHashNext(pE)){
            Table *pTab = (Table *)sqliteHashData(pE);
            if( pTab->tnum==(int)pgnoRoot ){
................................................................................
          }
        }
      }

      sqlite3_log(SQLITE_OK,
          "cannot commit CONCURRENT transaction "
          "- conflict at page %d "
          "(%s page; part of db %s %s%s%s)",
          (int)pgno,
          (bWrite==0?"read-only":(bWrite>0?"read/write":"unknown")),
          (zTab ? "index" : "table"),
          (zTab ? zTab : ""), (zTab ? "." : ""), (zObj ? zObj : "UNKNOWN")

      );
    }
  }
#endif
  sqlite3BtreeLeave(p);
  return rc;
}







>











>







 







|



|
>







10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
.....
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
#ifdef SQLITE_OMIT_CONCURRENT
  assert( pgno==0 );
#else
  if( rc==SQLITE_BUSY_SNAPSHOT && pgno ){
    PgHdr *pPg = 0;
    int rc2 = sqlite3PagerGet(pBt->pPager, pgno, &pPg, 0);
    if( rc2==SQLITE_OK ){
      u8 pageFlags = 0;
      int bWrite = -1;
      const char *zObj = 0;
      const char *zTab = 0;

      if( pPg ){
        Pgno pgnoRoot = 0;
        HashElem *pE;
        Schema *pSchema;

        pgnoRoot = ((MemPage*)sqlite3PagerGetExtra(pPg))->pgnoRoot;
        bWrite = sqlite3PagerIswriteable(pPg);
        pageFlags = ((u8*)sqlite3PagerGetData(pPg))[0];
        sqlite3PagerUnref(pPg);

        pSchema = sqlite3SchemaGet(p->db, p);
        if( pSchema ){
          for(pE=sqliteHashFirst(&pSchema->tblHash); pE; pE=sqliteHashNext(pE)){
            Table *pTab = (Table *)sqliteHashData(pE);
            if( pTab->tnum==(int)pgnoRoot ){
................................................................................
          }
        }
      }

      sqlite3_log(SQLITE_OK,
          "cannot commit CONCURRENT transaction "
          "- conflict at page %d "
          "(%s page; part of db %s %s%s%s; flags=0x%02x)",
          (int)pgno,
          (bWrite==0?"read-only":(bWrite>0?"read/write":"unknown")),
          (zTab ? "index" : "table"),
          (zTab ? zTab : ""), (zTab ? "." : ""), (zObj ? zObj : "UNKNOWN"),
          pageFlags
      );
    }
  }
#endif
  sqlite3BtreeLeave(p);
  return rc;
}

Changes to test/concurrent5.test.

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
..
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  db eval {
    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
  }

  catchsql COMMIT db2
} {1 {database is locked}}
do_test_conflict_msg 1.1.2 {
  conflict at page 2 (read-only page; part of db table t1)
}

do_test 1.2.1 {
  set ::log [list]
  db2 eval {
    ROLLBACK;
    BEGIN CONCURRENT;
................................................................................
    INSERT INTO t1 VALUES(12, 11);
  }

  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.2.2 {
  conflict at page 105 (read/write page; part of db table t1)
}

do_test 1.3.1 {
  set ::log [list]
  db2 eval {
    ROLLBACK;
    BEGIN CONCURRENT;
................................................................................
    INSERT INTO t2 VALUES('y');
  }

  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.3.2 {
  conflict at page 3 (read/write page; part of db table t2)
}

do_test 1.4.1 {
  set ::log [list]

  execsql {
    ROLLBACK;
................................................................................
  } db2

  execsql { INSERT INTO t3 VALUES(NULL, 5002) } db
  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.3.2 {
  conflict at page 211 (read/write page; part of db index t3.i3)
}

db close
db2 close
sqlite3_shutdown
test_sqlite3_log 
sqlite3_initialize
finish_test








|







 







|







 







|







 







|









55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
..
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
  db eval {
    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
  }

  catchsql COMMIT db2
} {1 {database is locked}}
do_test_conflict_msg 1.1.2 {
  conflict at page 2 (read-only page; part of db table t1; flags=0x05)
}

do_test 1.2.1 {
  set ::log [list]
  db2 eval {
    ROLLBACK;
    BEGIN CONCURRENT;
................................................................................
    INSERT INTO t1 VALUES(12, 11);
  }

  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.2.2 {
  conflict at page 105 (read/write page; part of db table t1; flags=0x0d)
}

do_test 1.3.1 {
  set ::log [list]
  db2 eval {
    ROLLBACK;
    BEGIN CONCURRENT;
................................................................................
    INSERT INTO t2 VALUES('y');
  }

  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.3.2 {
  conflict at page 3 (read/write page; part of db table t2; flags=0x0d)
}

do_test 1.4.1 {
  set ::log [list]

  execsql {
    ROLLBACK;
................................................................................
  } db2

  execsql { INSERT INTO t3 VALUES(NULL, 5002) } db
  catchsql COMMIT db2
} {1 {database is locked}}

do_test_conflict_msg 1.3.2 {
  conflict at page 211 (read/write page; part of db index t3.i3; flags=0x0a)
}

db close
db2 close
sqlite3_shutdown
test_sqlite3_log 
sqlite3_initialize
finish_test