/ Check-in [f6b025bf]
Login

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

Overview
Comment:Avoid reading the file-size before page 1 is read-locked.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | server-edition
Files: files | file ages | folders
SHA3-256: f6b025bf632501f51e691a05d309225671fd78bc62c9a43dd916d35ba4cf6d0e
User & Date: dan 2017-04-29 15:48:32
Context
2017-05-01
20:07
Update this branch with latest trunk changes. check-in: 83b1e163 user: dan tags: server-edition
2017-04-29
15:48
Avoid reading the file-size before page 1 is read-locked. check-in: f6b025bf user: dan tags: server-edition
2017-04-28
17:32
Fix various bugs revealed by running performance tests. check-in: a40b42c4 user: dan tags: server-edition
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/btree.c.

2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
....
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
  if( rc!=SQLITE_OK ) return rc;

  /* Do some checking to help insure the file we opened really is
  ** a valid database file. 
  */
  nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
  sqlite3PagerPagecount(pBt->pPager, &nPageFile);
#ifdef SQLITE_SERVER_EDITION
  if( sqlite3PagerIsServer(pBt->pPager) ){
    sqlite3PagerSetPagecount(pBt->pPager, nPage);
    nPageFile = nPage;
  }
#endif
  if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
    nPage = nPageFile;
  }
  if( nPage>0 ){
    u32 pageSize;
    u32 usableSize;
    u8 *page1 = pPage1->aData;
................................................................................
    int i;

    /* Try to lock a free-list trunk. If bAlloc is true, it has to be a
    ** free-list trunk with at least one entry in the free-list. */
    nList = (int)get4byte(&pNode->aData[4]);
    for(i=0; i<nList; i++){
      Pgno iTrunk = get4byte(&pNode->aData[8+i*4]);
      if( SQLITE_OK==sqlite3PagerWritelock(pBt->pPager, iTrunk) ){
        rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
        if( rc==SQLITE_OK && bAlloc ){
          if( !get4byte(&pTrunk->aData[0]) && !get4byte(&pTrunk->aData[4]) ){
            releasePage(pTrunk);
            pTrunk = 0;
          }
        }







<
<
<
<
<
<







 







|







2912
2913
2914
2915
2916
2917
2918






2919
2920
2921
2922
2923
2924
2925
....
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
  if( rc!=SQLITE_OK ) return rc;

  /* Do some checking to help insure the file we opened really is
  ** a valid database file. 
  */
  nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
  sqlite3PagerPagecount(pBt->pPager, &nPageFile);






  if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
    nPage = nPageFile;
  }
  if( nPage>0 ){
    u32 pageSize;
    u32 usableSize;
    u8 *page1 = pPage1->aData;
................................................................................
    int i;

    /* Try to lock a free-list trunk. If bAlloc is true, it has to be a
    ** free-list trunk with at least one entry in the free-list. */
    nList = (int)get4byte(&pNode->aData[4]);
    for(i=0; i<nList; i++){
      Pgno iTrunk = get4byte(&pNode->aData[8+i*4]);
      if( SQLITE_OK==sqlite3PagerPagelock(pBt->pPager, iTrunk, 1) ){
        rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
        if( rc==SQLITE_OK && bAlloc ){
          if( !get4byte(&pTrunk->aData[0]) && !get4byte(&pTrunk->aData[4]) ){
            releasePage(pTrunk);
            pTrunk = 0;
          }
        }

Changes to src/pager.c.

7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
}
#endif

#ifdef SQLITE_SERVER_EDITION
int sqlite3PagerIsServer(Pager *pPager){
  return pagerIsServer(pPager);
}
int sqlite3PagerWritelock(Pager *pPager, Pgno pgno){
  return sqlite3ServerLock(pPager->pServer, pgno, 1);
}
void sqlite3PagerSetPagecount(Pager *pPager, u32 nPage){
  assert( pPager->eState==PAGER_READER );
  pPager->dbSize = nPage;
}
#endif

#endif /* SQLITE_OMIT_DISKIO */







|
|
<
<
<
<




7663
7664
7665
7666
7667
7668
7669
7670
7671




7672
7673
7674
7675
}
#endif

#ifdef SQLITE_SERVER_EDITION
int sqlite3PagerIsServer(Pager *pPager){
  return pagerIsServer(pPager);
}
int sqlite3PagerPagelock(Pager *pPager, Pgno pgno, int bWrite){
  return sqlite3ServerLock(pPager->pServer, pgno, bWrite);




}
#endif

#endif /* SQLITE_OMIT_DISKIO */

Changes to src/pager.h.

235
236
237
238
239
240
241
242
243
244
245
246
# define disable_simulated_io_errors()
# define enable_simulated_io_errors()
#endif

#ifdef SQLITE_SERVER_EDITION
  int sqlite3PagerRollbackJournal(Pager*, int);
  int sqlite3PagerIsServer(Pager *pPager);
  int sqlite3PagerWritelock(Pager *pPager, Pgno);
  void sqlite3PagerSetPagecount(Pager*, u32);
#endif

#endif /* SQLITE_PAGER_H */







|
<



235
236
237
238
239
240
241
242

243
244
245
# define disable_simulated_io_errors()
# define enable_simulated_io_errors()
#endif

#ifdef SQLITE_SERVER_EDITION
  int sqlite3PagerRollbackJournal(Pager*, int);
  int sqlite3PagerIsServer(Pager *pPager);
  int sqlite3PagerPagelock(Pager *pPager, Pgno, int);

#endif

#endif /* SQLITE_PAGER_H */

Changes to src/server.c.

395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
/*
** Begin a transaction.
*/
int sqlite3ServerBegin(Server *p){
#if 0
  return posixLock(p->pHma->fd, p->iClient+1, SERVER_WRITE_LOCK, 0);
#endif
  return SQLITE_OK;
}

/*
** End a transaction (and release all locks).
*/
int sqlite3ServerEnd(Server *p){
  int i;







|







395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
/*
** Begin a transaction.
*/
int sqlite3ServerBegin(Server *p){
#if 0
  return posixLock(p->pHma->fd, p->iClient+1, SERVER_WRITE_LOCK, 0);
#endif
  return sqlite3ServerLock(p, 1, 0);
}

/*
** End a transaction (and release all locks).
*/
int sqlite3ServerEnd(Server *p){
  int i;