]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/lei-store-format.pod
71aa72cb96e3b6d9a03dce1680f11e9848ee40c9
[public-inbox.git] / Documentation / lei-store-format.pod
1 % public-inbox developer manual
2
3 =head1 NAME
4
5 lei-store-format - lei/store format description
6
7 =head1 DESCRIPTION
8
9 C<lei/store> is a hybrid store based on L<public-inbox-extindex-format(5)>
10 ("extindex") combined with L<public-inbox-v2-format(5)> ("v2") for blob
11 storage.  While v2 is ideal for archiving a single public mailing list;
12 it was never intended for personal mail nor storing multiple
13 blobs of the "same" message.
14
15 As with extindex, it can index disparate C<List-Id> headers
16 belonging to the "same" message with different git blob OIDs.
17 Unlike v2 and extindex, C<Message-ID> headers are NOT required;
18 allowing unsent draft messages to be stored and indexed.
19
20 =head1 DIRECTORY LAYOUT
21
22 Blob storage exists in the form of v2-style epochs.  These epochs
23 are under the C<local/> directory (instead of C<git/>) to
24 prevent them from being accidentally treated as a v2 inbox.
25
26 =head2 INDEX OVERVIEW AND DEFINITIONS
27
28   $EPOCH - Integer starting with 0 based on time
29   $SCHEMA_VERSION - DB schema version (for Xapian)
30   $SHARD - Integer starting with 0 based on parallelism
31
32   ~/.local/share/lei/store
33   - ipc.lock                        # lock file for internal lei IPC
34   - local/$EPOCH.git                # normal bare git repositories
35   - mail_sync.sqlite3               # sync state IMAP, Maildir, NNTP
36
37 Additionally, the following share the same roles they do in extindex:
38
39   - ei.lock                         # lock file to protect global state
40   - ALL.git                         # empty, alternates for local/*.git
41   - ei$SCHEMA_VERSION/$SHARD        # per-shard Xapian DB
42   - ei$SCHEMA_VERSION/over.sqlite3  # overview DB for WWW, IMAP
43   - ei$SCHEMA_VERSION/misc          # misc Xapian DB
44
45 =head2 XREF3 DEDUPLICATION
46
47 Index deduplication follows extindex, see
48 L<public-inbox-extindex-format(5)/XREF3 DEDUPLICATION> for
49 more information.
50
51 =head2 BLOB DEDUPLICATION
52
53 The contents of C<local/*.git> repos is deduplicated by git blob
54 object IDs (currently SHA-1).  This allows multiple copies of
55 cross-posted and personally Cc-ed messages to be stored with
56 different C<Received:>, C<X-Spam-Status:> and similar headers to
57 allow troubleshooting.
58
59 =head2 VOLATILE METADATA
60
61 Keywords and label information (as described in RFC 8621 for JMAP)
62 is stored in existing Xapian shards (C<ei$SCHEMA_VERSION/$SHARD>).
63 It is possible to search for messages matching labels and
64 keywords using C<L:> and C<kw:>, respectively.  As with all data
65 stored in Xapian indices, volatile metadata is associated with
66 the Xapian document, thus it is shared across different blobs of
67 the "same" message.
68
69 =head1 IPC
70
71 When L<lei(1)> is run in daemon mode, L<flock(2)> is used on
72 C<ipc.lock> is used to serialize writes to C<lei/store> across
73 multiple internal lei workers while minimizing commits.
74
75 =head1 CAVEATS
76
77 Reindexing and synchronization is not yet supported.
78
79 =head1 THANKS
80
81 Thanks to the Linux Foundation for sponsoring the development
82 and testing.
83
84 =head1 COPYRIGHT
85
86 Copyright 2021 all contributors L<mailto:meta@public-inbox.org>
87
88 License: AGPL-3.0+ L<http://www.gnu.org/licenses/agpl-3.0.txt>
89
90 =head1 SEE ALSO
91
92 L<public-inbox-v2-format(5)>, L<public-inbox-extindex(5)>