SQLite4
Check-in [723d5f2f52]
Not logged in

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

Overview
Comment:Add a test to verify that an lsm_close() that disconnects the last connection to a database flushes the in-memory tree regardless of the multi-process or use-log settings.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | read-only-clients
Files: files | file ages | folders
SHA1: 723d5f2f5279b70b646f904a18cbe9da981efcd7
User & Date: dan 2013-02-20 17:54:41
Context
2013-02-20
18:06
Merge read-only-clients branch with trunk. check-in: 66fe3644fd user: dan tags: trunk
17:54
Add a test to verify that an lsm_close() that disconnects the last connection to a database flushes the in-memory tree regardless of the multi-process or use-log settings. Leaf check-in: 723d5f2f52 user: dan tags: read-only-clients
16:03
Instead of locking the CHECKPOINTER byte, have read-only connections take a SHARED lock on the ROTRANS byte when reading from a non-live db. Read-write connections may not recycle space within either the database or log files while such a lock is held, but may perform checkpoint operations. check-in: 3b2a50c089 user: dan tags: read-only-clients
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/lsmInt.h.

132
133
134
135
136
137
138
139

140
141
142
143
144
145
146

/* The number of available read locks. */
#define LSM_LOCK_NREADER   6

/* The number of available read-write client locks. */
#define LSM_LOCK_NRWCLIENT   16

/* Lock definitions. */

#define LSM_LOCK_DMS1         1   /* Serialize connect/disconnect ops */
#define LSM_LOCK_DMS2         2   /* Read-write connections */
#define LSM_LOCK_DMS3         3   /* Read-only connections */
#define LSM_LOCK_WRITER       4
#define LSM_LOCK_WORKER       5
#define LSM_LOCK_CHECKPOINTER 6
#define LSM_LOCK_ROTRANS      7







|
>







132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147

/* The number of available read locks. */
#define LSM_LOCK_NREADER   6

/* The number of available read-write client locks. */
#define LSM_LOCK_NRWCLIENT   16

/* Lock definitions. 
*/
#define LSM_LOCK_DMS1         1   /* Serialize connect/disconnect ops */
#define LSM_LOCK_DMS2         2   /* Read-write connections */
#define LSM_LOCK_DMS3         3   /* Read-only connections */
#define LSM_LOCK_WRITER       4
#define LSM_LOCK_WORKER       5
#define LSM_LOCK_CHECKPOINTER 6
#define LSM_LOCK_ROTRANS      7

Changes to test/lsm5.test.

10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#***********************************************************************
#
# The focus of this file is testing the LSM library. 
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

set testprefix lsm5
db close

proc db_fetch {db key} {
  db csr_open csr
  csr seek $key eq
  set ret [csr value]
  csr close
  set ret
}

# Create a new database with file name $file.
#
proc create_abc_db {file} {
  forcedelete $file
  lsm_open db $file {block_size 256}
  db write a alpha
  db write b bravo







>



<
<
<
<
<
<
<
<







10
11
12
13
14
15
16
17
18
19
20








21
22
23
24
25
26
27
#***********************************************************************
#
# The focus of this file is testing the LSM library. 
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lsm_common.tcl
set testprefix lsm5
db close









# Create a new database with file name $file.
#
proc create_abc_db {file} {
  forcedelete $file
  lsm_open db $file {block_size 256}
  db write a alpha
  db write b bravo

Added test/lsm6.test.





































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 2013 February 20
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# The focus of this file is testing the LSM library. Specifically, it
# checks that the in-memory tree is flushed to disk when the last connection
# is closed.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lsm_common.tcl
set testprefix lsm6
db close

foreach {tn mp lf} {
         1  1  1
         2  1  0
         3  0  1
         4  0  0
} {

  do_test $tn.1 {
    forcedelete test.db test.db-log
    lsm_open db test.db [list multi_proc $mp use_log $lf]
    for {set i 0} {$i < 1000} {incr i} {
      db write $i [string repeat "$i." 1000]
    }
    expr {[file size test.db-log] > 0}
  } $lf

  do_test $tn.2 {
    db close
    lsm_open db test.db 
    db_fetch db 999
  } [string repeat 999. 1000]

  db close
}

finish_test


Added test/lsm_common.tcl.



















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 2013 Feb 20
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains common code used the various lsm tests in this
# directory.
#


proc db_fetch {db key} {
  db csr_open csr
  csr seek $key eq
  set ret [csr value]
  csr close
  set ret
}