]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/lei-store-format.pod
625c60f436a8cb3361e905f30e3b4c0a12239252
[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   - local/$EPOCH.git                # normal bare git repositories
34   - mail_sync.sqlite3               # sync state IMAP, Maildir, NNTP
35
36 Additionally, the following share the same roles they do in extindex:
37
38   - ei.lock                         # lock file to protect global state
39   - ALL.git                         # empty, alternates for local/*.git
40   - ei$SCHEMA_VERSION/$SHARD        # per-shard Xapian DB
41   - ei$SCHEMA_VERSION/over.sqlite3  # overview DB for WWW, IMAP
42   - ei$SCHEMA_VERSION/misc          # misc Xapian DB
43
44 =head2 XREF3 DEDUPLICATION
45
46 Index deduplication follows extindex, see
47 L<public-inbox-extindex-format(5)/XREF3 DEDUPLICATION> for
48 more information.
49
50 =head2 BLOB DEDUPLICATION
51
52 The contents of C<local/*.git> repos is deduplicated by git blob
53 object IDs (currently SHA-1).  This allows multiple copies of
54 cross-posted and personally Cc-ed messages to be stored with
55 different C<Received:>, C<X-Spam-Status:> and similar headers to
56 allow troubleshooting.
57
58 =head2 VOLATILE METADATA
59
60 Keywords and label information (as described in RFC 8621 for JMAP)
61 is stored in existing Xapian shards (C<ei$SCHEMA_VERSION/$SHARD>).
62 It is possible to search for messages matching labels and
63 keywords using C<L:> and C<kw:>, respectively.  As with all data
64 stored in Xapian indices, volatile metadata is associated with
65 the Xapian document, thus it is shared across different blobs of
66 the "same" message.
67
68 =head2 mail_sync.sqlite3
69
70 This SQLite database maintained for bidirectional mapping of
71 git blobs to IMAP UIDs, Maildir file names, and NNTP article numbers.
72
73 It is also used for retrieving messages from Maildirs indexed by
74 L<lei-index(1)>.
75
76 =head1 IPC
77
78 L<lei-daemon(8)> communicates with the C<lei/store> process using
79 L<unix(7)> C<SOCK_SEQPACKET> sockets.
80
81 =head1 CAVEATS
82
83 Reindexing and synchronization is not yet supported.
84
85 =head1 THANKS
86
87 Thanks to the Linux Foundation for sponsoring the development
88 and testing.
89
90 =head1 COPYRIGHT
91
92 Copyright 2021 all contributors L<mailto:meta@public-inbox.org>
93
94 License: AGPL-3.0+ L<http://www.gnu.org/licenses/agpl-3.0.txt>
95
96 =head1 SEE ALSO
97
98 L<public-inbox-v2-format(5)>, L<public-inbox-extindex(5)>