/ Check-in [e7dc03e7]
Login
Overview
Comment:Instead of just the flags byte, include the first 8 bytes of the relevant page in an on-commit conflict log message.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent
Files: files | file ages | folders
SHA3-256:e7dc03e7439f224e4bec458f27fe364f2fb1ac637328657a578ada693ae22842
User & Date: dan 2018-05-15 11:28:36
Context
2018-05-15
11:45
Merge latest trunk changes with this branch. Leaf check-in: ae86cf60 user: dan tags: begin-concurrent
11:33
Instead of just the flags byte, include the first 8 bytes of the relevant page in an on-commit conflict log message. check-in: 52e443eb user: dan tags: begin-concurrent-pnu
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
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
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
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;
}







<



>





>
>
>
>
>
>
>
>
>
>
>



<







 







|




|







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
10456
10457
10458

10459
10460
10461
10462
10463
10464
10465
.....
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
#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;
      char zContent[17];

      if( pPg ){
        Pgno pgnoRoot = 0;
        HashElem *pE;
        Schema *pSchema;
        u8 *aData = (u8*)sqlite3PagerGetData(pPg);
        int i;
        for(i=0; i<8; i++){
          static const char hexdigits[] = {
            '0', '1', '2', '3', '4', '5', '6', '7',
            '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 
          };
          zContent[i*2] = hexdigits[(aData[i] >> 4)];
          zContent[i*2+1] = hexdigits[(aData[i] & 0xF)];
        }
        zContent[16] = '\0';

        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; content=%s...)",
          (int)pgno,
          (bWrite==0?"read-only":(bWrite>0?"read/write":"unknown")),
          (zTab ? "index" : "table"),
          (zTab ? zTab : ""), (zTab ? "." : ""), (zObj ? zObj : "UNKNOWN"),
          zContent
      );
    }
  }
#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; 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








|







 







|







 







|







 







|









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; content=0500000063021100...)
}

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; content=0D00000002026100...)
}

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; content=0D0000000103FB00...)
}

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; content=0A0310006300D800...)
}

db close
db2 close
sqlite3_shutdown
test_sqlite3_log 
sqlite3_initialize
finish_test