lmdb

Check-in [b91e1e29c7]
Login

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

Overview
Comment:Stale transaction cleanup
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b91e1e29c75e1cd1b7919548917abb160a09cfde62fe677ad7b6bc4627806774
User & Date: murphy 2018-08-25 12:58:47
Context
2018-09-01
16:02
#:limit support for database-fold and friends check-in: d4ff8cd366 user: murphy tags: trunk
2018-08-25
12:58
Stale transaction cleanup check-in: b91e1e29c7 user: murphy tags: trunk
2018-08-20
22:04
Initial test suite check-in: f971d52bba user: murphy tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lmdb.scm.

1
2
3
4
5
6
7
8
9
10
11
12
13
...
246
247
248
249
250
251
252


253
254
255
256
257
258
259
...
302
303
304
305
306
307
308










309
310
311
312
313
314
315
(module lmdb
  (database-environment?
   current-database-environment
   open-database-environment close-database-environment
   copy-database-environment
   with-transaction
   database?
   open-database close-database drop-database
   database-ref database-set! database-exists? database-delete!
   database-fold database-walk
   database->alist alist->database)

(import
................................................................................
      (create-directory path))
    (check-error
     'copy-database-environment
     ((foreign-lambda
       int "mdb_env_copy2"
       nonnull-database-environment nonnull-c-string unsigned-int)
      env path flags))))



(define-foreign-tagged-type (transaction nonnull-transaction "MDB_txn")
  transaction?
  tag:transaction)

(define current-transaction
  (make-parameter #f))
................................................................................
                   nonnull-transaction)
                  txn))
                ((foreign-lambda
                  void "mdb_txn_abort"
                  nonnull-transaction)
                 txn))
            (set! complete? #t)))))))











;; Databases

(define-record-type database
  (wrap-database dbi)
  database?
  [dbi unwrap-database])





|







 







>
>







 







>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
...
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
...
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
(module lmdb
  (database-environment?
   current-database-environment
   open-database-environment close-database-environment
   copy-database-environment
   with-transaction clear-stale-transactions
   database?
   open-database close-database drop-database
   database-ref database-set! database-exists? database-delete!
   database-fold database-walk
   database->alist alist->database)

(import
................................................................................
      (create-directory path))
    (check-error
     'copy-database-environment
     ((foreign-lambda
       int "mdb_env_copy2"
       nonnull-database-environment nonnull-c-string unsigned-int)
      env path flags))))

;; Transactions

(define-foreign-tagged-type (transaction nonnull-transaction "MDB_txn")
  transaction?
  tag:transaction)

(define current-transaction
  (make-parameter #f))
................................................................................
                   nonnull-transaction)
                  txn))
                ((foreign-lambda
                  void "mdb_txn_abort"
                  nonnull-transaction)
                 txn))
            (set! complete? #t)))))))

(define (clear-stale-transactions #!optional [env (current-database-environment)])
  (let-location ([dead int 0])
    (check-error
     'clear-stale-transactions
     ((foreign-lambda
       int "mdb_reader_check"
       nonnull-database-environment (c-pointer int))
      env (location dead)))
    dead))

;; Databases

(define-record-type database
  (wrap-database dbi)
  database?
  [dbi unwrap-database])

Changes to lmdb.wiki.

66
67
68
69
70
71
72


73
74
75
76
77
78

79
80
81
82
83
84
85
86
87










88
89
90
91
92
93
94
  (copy-database-environment PATH [ENVIRONMENT] [#:compact]) => VOID
</verbatim>

Copies a database environment to a new <tt>PATH</tt>, optionally
compacting the data. If no <tt>ENVIRONMENT</tt> is specified
explicitly, the current environment is copied.



<verbatim>
  (with-transaction THUNK [#:read-only]) => (values ...)
</verbatim>

Wraps a call to <tt>THUNK</tt> in a transaction. Returns whatever
<tt>(THUNK)</tt> returns.


The transaction can optionally be configured as read-only. Read-only
transactions may be nested.

All database operations below have to be executed within a transaction.

The transaction is committed upon normal return from <tt>(THUNK)</tt>
and aborted if <tt>(THUNK)</tt> throws an exception.











<h2>Databases</h2>

<verbatim>
  (database? OBJECT) => BOOLEAN
</verbatim>

Type predicate for databases.







>
>

|



|
>









>
>
>
>
>
>
>
>
>
>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  (copy-database-environment PATH [ENVIRONMENT] [#:compact]) => VOID
</verbatim>

Copies a database environment to a new <tt>PATH</tt>, optionally
compacting the data. If no <tt>ENVIRONMENT</tt> is specified
explicitly, the current environment is copied.

<h2>Transactions</h2>

<verbatim>
  (with-transaction THUNK [ENVIRONMENT] [#:read-only]) => (values ...)
</verbatim>

Wraps a call to <tt>THUNK</tt> in a transaction. Returns whatever
<tt>(THUNK)</tt> returns. If no <tt>ENVIRONMENT</tt> is specified
explicitly, the current environment is used.

The transaction can optionally be configured as read-only. Read-only
transactions may be nested.

All database operations below have to be executed within a transaction.

The transaction is committed upon normal return from <tt>(THUNK)</tt>
and aborted if <tt>(THUNK)</tt> throws an exception.

<verbatim>
  (clear-stale-transactions [ENVIRONMENT]) => INTEGER
</verbatim>
 
Removes stale read-only transactions from the database lockfile (stale
read-write transactions are usually removed automatically). If no
<tt>ENVIRONMENT</tt> is specified explicitly, the current environment is used.

The procedure returns the number of stale lock file entries that were removed.

<h2>Databases</h2>

<verbatim>
  (database? OBJECT) => BOOLEAN
</verbatim>

Type predicate for databases.