Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Simplify the way in which the database file is truncated when the last connection disconnects. Also ignore the error code from the xTruncate call - as truncating a database file is always optional. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b0a49d90fc91acca1306cf6145adc83a |
User & Date: | dan 2017-07-11 19:55:38.241 |
Context
2017-07-11
| ||
20:36 | In lsm, attempt to unmap the database file before truncating it when disconnecting. A mapped file may not be truncated on win32. (check-in: 39069941e9 user: dan tags: trunk) | |
19:55 | Simplify the way in which the database file is truncated when the last connection disconnects. Also ignore the error code from the xTruncate call - as truncating a database file is always optional. (check-in: b0a49d90fc user: dan tags: trunk) | |
18:11 | Fix harmless compiler warnings in the core. (check-in: 55e93f2560 user: drh tags: trunk) | |
Changes
Changes to ext/lsm1/lsmInt.h.
︙ | ︙ | |||
585 586 587 588 589 590 591 | u32 nWrite; /* Total number of pages written to disk */ }; #define LSM_INITIAL_SNAPSHOT_ID 11 /* ** Functions from file "lsm_ckpt.c". */ | | | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | u32 nWrite; /* Total number of pages written to disk */ }; #define LSM_INITIAL_SNAPSHOT_ID 11 /* ** Functions from file "lsm_ckpt.c". */ int lsmCheckpointWrite(lsm_db *, u32 *); int lsmCheckpointLevels(lsm_db *, int, void **, int *); int lsmCheckpointLoadLevels(lsm_db *pDb, void *pVal, int nVal); int lsmCheckpointRecover(lsm_db *); int lsmCheckpointDeserialize(lsm_db *, int, u32 *, Snapshot **); int lsmCheckpointLoadWorker(lsm_db *pDb); |
︙ | ︙ |
Changes to ext/lsm1/lsm_shared.c.
︙ | ︙ | |||
226 227 228 229 230 231 232 | ** contains data. */ ctx.nBlock = pDb->pWorker->nBlock; ctx.iInUse = -1; rc = lsmWalkFreelist(pDb, 1, dbTruncateCb, (void *)&ctx); /* If the last block that contains data is not already the last block in ** the database file, truncate the database file so that it is. */ | | | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | ** contains data. */ ctx.nBlock = pDb->pWorker->nBlock; ctx.iInUse = -1; rc = lsmWalkFreelist(pDb, 1, dbTruncateCb, (void *)&ctx); /* If the last block that contains data is not already the last block in ** the database file, truncate the database file so that it is. */ if( rc==LSM_OK ){ rc = lsmFsTruncateDb( pDb->pFS, (i64)ctx.nBlock*lsmFsBlockSize(pDb->pFS) ); } } lsmFreeSnapshot(pDb->pEnv, pDb->pWorker); |
︙ | ︙ | |||
289 290 291 292 293 294 295 | bReadonly = 1; rc = LSM_OK; } } /* Write a checkpoint to disk. */ if( rc==LSM_OK ){ | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | bReadonly = 1; rc = LSM_OK; } } /* Write a checkpoint to disk. */ if( rc==LSM_OK ){ rc = lsmCheckpointWrite(pDb, 0); } /* If the checkpoint was written successfully, delete the log file ** and, if possible, truncate the database file. */ if( rc==LSM_OK ){ int bRotrans = 0; Database *p = pDb->pDatabase; |
︙ | ︙ | |||
910 911 912 913 914 915 916 | ** database itself. ** ** The WORKER lock must not be held when this is called. This is because ** this function may indirectly call fsync(). And the WORKER lock should ** not be held that long (in case it is required by a client flushing an ** in-memory tree to disk). */ | | | 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | ** database itself. ** ** The WORKER lock must not be held when this is called. This is because ** this function may indirectly call fsync(). And the WORKER lock should ** not be held that long (in case it is required by a client flushing an ** in-memory tree to disk). */ int lsmCheckpointWrite(lsm_db *pDb, u32 *pnWrite){ int rc; /* Return Code */ u32 nWrite = 0; assert( pDb->pWorker==0 ); assert( 1 || pDb->pClient==0 ); assert( lsmShmAssertLock(pDb, LSM_LOCK_WORKER, LSM_LOCK_UNLOCK) ); |
︙ | ︙ | |||
965 966 967 968 969 970 971 | } #ifdef LSM_LOG_WORK lsmLogMessage(pDb, 0, "finish checkpoint %d", (int)lsmCheckpointId(pDb->aSnapshot, 0) ); #endif } | < < < < | 965 966 967 968 969 970 971 972 973 974 975 976 977 978 | } #ifdef LSM_LOG_WORK lsmLogMessage(pDb, 0, "finish checkpoint %d", (int)lsmCheckpointId(pDb->aSnapshot, 0) ); #endif } } lsmShmLock(pDb, LSM_LOCK_CHECKPOINTER, LSM_LOCK_UNLOCK, 0); if( pnWrite && rc==LSM_OK ) *pnWrite = nWrite; return rc; } |
︙ | ︙ | |||
1962 1963 1964 1965 1966 1967 1968 | int lsm_checkpoint(lsm_db *pDb, int *pnKB){ int rc; /* Return code */ u32 nWrite = 0; /* Number of pages checkpointed */ /* Attempt the checkpoint. If successful, nWrite is set to the number of ** pages written between this and the previous checkpoint. */ | | | 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 | int lsm_checkpoint(lsm_db *pDb, int *pnKB){ int rc; /* Return code */ u32 nWrite = 0; /* Number of pages checkpointed */ /* Attempt the checkpoint. If successful, nWrite is set to the number of ** pages written between this and the previous checkpoint. */ rc = lsmCheckpointWrite(pDb, &nWrite); /* If required, calculate the output variable (KB of data checkpointed). ** Set it to zero if an error occured. */ if( pnKB ){ int nKB = 0; if( rc==LSM_OK && nWrite ){ nKB = (((i64)nWrite * lsmFsPageSize(pDb->pFS)) + 1023) / 1024; } *pnKB = nKB; } return rc; } |