Hey. I have a question about shutting down Typesen...
# community-help
a
Hey. I have a question about shutting down Typesense and persistence. I see TS handles SIGINT to perform a graceful shutdown. Are all documents which are currently in-memory flushed to disk before shutdown? Or does this happen only periodically? Is this interval controlled by
--snapshot-interval-seconds
?
k
During indexing the documents are written to disk and also indexed in-memory. On restart, the documents from disk are reindexed into memory again. So the raw documents are persisted, while the index is in-memory and ephemeral.
a
Gotcha. So the on-disk state is always up-to-date with the state in memory? Modulo
fsync
shenanigans, of course?
k
Correct
a
Terrific. Thanks for your help!
👍 1
Is there maybe a bug in 29.0 when it logs what it's doing on startup when reading collections? I see logs like this
Copy code
I20250813 14:34:30.965727     1 typesense_server_utils.cpp:362] Starting Typesense 29.0                                                                                                                                                                                  
I20250813 14:34:30.965786     1 typesense_server_utils.cpp:365] Typesense is using jemalloc.                                                                                                                                                                             
I20250813 14:34:30.965934     1 typesense_server_utils.cpp:432] Thread pool size: 64                                                                                                                                                                                     
I20250813 14:34:30.976864     1 store.cpp:39] Initializing DB by opening state dir: /data/db                                                                                                                                                                             
I20250813 14:34:31.016042     1 store.cpp:39] Initializing DB by opening state dir: /data/meta                                                                                                                                                                           
I20250813 14:34:31.053706     1 ratelimit_manager.cpp:546] Loaded 0 rate limit rules.                                                                                                                                                                                    
I20250813 14:34:31.053723     1 ratelimit_manager.cpp:547] Loaded 0 rate limit bans.                                                                                                                                                                                     
I20250813 14:34:31.053865     1 typesense_server_utils.cpp:536] Loaded 0 natural language search model(s).                                                                                                                                                               
I20250813 14:34:31.053943     1 typesense_server_utils.cpp:608] Starting API service...                                                                                                                                                                                  
I20250813 14:34:31.054126     1 http_server.cpp:180] Typesense has started listening on port 8108                                                                                                                                                                        
I20250813 14:34:31.055101   262 typesense_server_utils.cpp:261] Since no --nodes argument is provided, starting a single node Typesense cluster.                                                                                                                         
I20250813 14:34:31.055874   263 batched_indexer.cpp:196] Starting batch indexer with 64 threads.                                                                                                                                                                         
I20250813 14:34:31.059327   265 typesense_server_utils.cpp:551] Conversation garbage collector thread started.                                                                                                                                                           
I20250813 14:34:31.065815   263 batched_indexer.cpp:201] BatchedIndexer skip_index: -9999                                                                                                                                                                                
I20250813 14:34:31.066362   341 batched_indexer.cpp:353] Starting reference sequence thread.                                                                                                                                                                             
I20250813 14:34:31.067438   262 server.cpp:1181] Server[braft::RaftStatImpl+braft::FileServiceImpl+braft::RaftServiceImpl+braft::CliServiceImpl] is serving on port=8107.                                                                                                
I20250813 14:34:31.067454   262 server.cpp:1184] Check out <http://typesensev2-0:8107> in web browser.                                                                                                                                                                     
I20250813 14:34:31.068885   262 raft_server.cpp:75] Nodes configuration: 10.0.0.57:8107:8108                                                                                                                                                                             
I20250813 14:34:31.069129   262 raft_server.cpp:118] Snapshot does not exist. We will remove db dir and init db fresh.                                                                                                                                                   
I20250813 14:34:31.075687   262 store.cpp:245] rm /data/db success                                                                                                                                                                                                       
I20250813 14:34:31.076068   262 store.cpp:39] Initializing DB by opening state dir: /data/db                                                                                                                                                                             
I20250813 14:34:31.101820   262 store.cpp:269] DB open success!                                                                                                                                                                                                          
I20250813 14:34:31.101846   262 raft_server.cpp:598] Loading collections from disk...                                                                                                                                                                                    
I20250813 14:34:31.101871   262 collection_manager.cpp:385] CollectionManager::load()                                                                                                                                                                                    
I20250813 14:34:31.102051   262 auth_manager.cpp:35] Indexing 0 API key(s) found on disk.                                                                                                                                                                                
I20250813 14:34:31.102078   262 collection_manager.cpp:421] Loading upto 32 collections in parallel, 1000 documents at a time.                                                                                                                                           
I20250813 14:34:31.102104   262 collection_manager.cpp:430] Found 0 collection(s) on disk.                                                                                                                                                                               
I20250813 14:34:31.103437   262 collection_manager.cpp:586] Loaded 0 collection(s).
Not sure what to make of these lines:
Copy code
Snapshot does not exist. We will remove db dir and init db fresh
rm /data/db success
and
Copy code
Loaded 0 collection(s).
even though several collections and documents were in fact loaded 🤷
k
Data is loaded from the snapshot first, which is controlled by
snapshot-interval-seconds
. If server had restarted before a snapshot had run, it won't find any collections in snapshot. Once snapshot is restored, Raft WAL / log is played
The collections you created will exist in WAL
a
Makes sense! Thanks again 👌