This message was deleted.
# community-help
s
This message was deleted.
g
Actually it never heals even after loading the 27M docs.
Copy code
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.174031   228 collection_manager.cpp:1438] Indexed 26126793/26126793 documents into collection companiesfr_alias_26112023_37017
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.181952   228 collection_manager.cpp:255] Loaded 4 collection(s) so far
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200186   192 collection_manager.cpp:316] Loaded 4 collection(s).
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200690   192 collection_manager.cpp:320] Initializing batched indexer from snapshot state...
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200733   192 batched_indexer.cpp:447] Restored 0 in-flight requests from snapshot.
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200742   192 raft_server.cpp:515] Finished loading collections from disk.
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200764   192 raft_server.h:283] Configuration of this group is 10.0.5.23:8107:8108
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.202894   192 snapshot_executor.cpp:264] node default_group:10.0.5.24:8107:8108 snapshot_load_done, last_included_index: 21709 last_included_term: 4 peers: "10.0.5.23:8107:8108"
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.203541   166 raft_meta.cpp:521] Loaded single stable meta, path /data/state/meta term 4 votedfor 10.0.5.23:8107:8108 time: 456
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.203580   166 node.cpp:608] node default_group:10.0.5.24:8107:8108 init, term: 4 last_log_id: (index=29035,term=4) conf: 10.0.5.23:8107:8108 old_conf: 
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.203622   166 raft_server.cpp:134] Node last_index: 29035
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.174031   228 collection_manager.cpp:1438] Indexed 26126793/26126793 documents into collection companiesfr_alias_26112023_37017
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.181952   228 collection_manager.cpp:255] Loaded 4 collection(s) so far
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200186   192 collection_manager.cpp:316] Loaded 4 collection(s).
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200690   192 collection_manager.cpp:320] Initializing batched indexer from snapshot state...
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200733   192 batched_indexer.cpp:447] Restored 0 in-flight requests from snapshot.
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200742   192 raft_server.cpp:515] Finished loading collections from disk.
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.200764   192 raft_server.h:283] Configuration of this group is 10.0.5.23:8107:8108
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.202894   192 snapshot_executor.cpp:264] node default_group:10.0.5.24:8107:8108 snapshot_load_done, last_included_index: 21709 last_included_term: 4 peers: "10.0.5.23:8107:8108"
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.203541   166 raft_meta.cpp:521] Loaded single stable meta, path /data/state/meta term 4 votedfor 10.0.5.23:8107:8108 time: 456
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.203580   166 node.cpp:608] node default_group:10.0.5.24:8107:8108 init, term: 4 last_log_id: (index=29035,term=4) conf: 10.0.5.23:8107:8108 old_conf: 
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:37:55.203622   166 raft_server.cpp:134] Node last_index: 29035
...
It keeps looping
Copy code
app_search.1.alz15ut0nvcg@formalist    | W20231126 20:43:15.263285   166 node.cpp:843] [default_group:10.0.5.24:8107:8108 ] Refusing concurrent configuration changing
app_search.1.alz15ut0nvcg@formalist    | E20231126 20:43:15.263331   192 raft_server.h:62] Peer refresh failed, error: Doing another configuration change
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:43:17.284148   167 batched_indexer.cpp:285] Running GC for aborted requests, req map size: 157
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:43:25.264204   166 raft_server.cpp:564] Term: 6, last_index index: 29036, committed_index: 29036, known_applied_index: 21709, applying_index: 25020, queued_writes: 2083, pending_queue_size: 0, local_sequence: 108050116
app_search.1.alz15ut0nvcg@formalist    | W20231126 20:43:25.264320   166 node.cpp:843] [default_group:10.0.5.24:8107:8108 ] Refusing concurrent configuration changing
app_search.1.alz15ut0nvcg@formalist    | E20231126 20:43:25.264405   192 raft_server.h:62] Peer refresh failed, error: Doing another configuration change
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:43:35.267424   166 raft_server.cpp:564] Term: 6, last_index index: 29036, committed_index: 29036, known_applied_index: 21709, applying_index: 25108, queued_writes: 2140, pending_queue_size: 0, local_sequence: 108170796
app_search.1.alz15ut0nvcg@formalist    | W20231126 20:43:35.267467   166 node.cpp:843] [default_group:10.0.5.24:8107:8108 ] Refusing concurrent configuration changing
app_search.1.alz15ut0nvcg@formalist    | E20231126 20:43:35.267534   192 raft_server.h:62] Peer refresh failed, error: Doing another configuration change
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:43:45.268357   166 raft_server.cpp:564] Term: 6, last_index index: 29036, committed_index: 29036, known_applied_index: 21709, applying_index: 25115, queued_writes: 2153, pending_queue_size: 0, local_sequence: 108170810
app_search.1.alz15ut0nvcg@formalist    | W20231126 20:43:45.268409   166 node.cpp:843] [default_group:10.0.5.24:8107:8108 ] Refusing concurrent configuration changing
app_search.1.alz15ut0nvcg@formalist    | E20231126 20:43:45.268452   192 raft_server.h:62] Peer refresh failed, error: Doing another configuration change
app_search.1.alz15ut0nvcg@formalist    | I20231126 20:43:55.269358   166 raft_server.cpp:564] Term: 6, last_index index: 29036, committed_index: 29036, known_applied_index: 21709, applying_index: 25118, queued_writes: 2153, pending_queue_size: 0, local_sequence: 108170816
app_search.1.alz15ut0nvcg@formalist    | W20231126 20:43:55.269407   166 node.cpp:843] [default_group:10.0.5.24:8107:8108 ] Refusing concurrent configuration changing
app_search.1.alz15ut0nvcg@formalist    | E20231126 20:43:55.269483   192 raft_server.h:62] Peer refresh failed, error: Doing another configuration change
Maybe a github issue is a better reporting place?
Copy code
command: '--data-dir /data --api-key=${TYPESENSE_API_KEY} --num-documents-parallel-load=5000 --enable-cors --nodes=10.132.0.4 --healthy-read-lag=5000 --healthy-write-lag=10000 --cors-domains=http://localhost:8000'
j
This doesn't look like a crash. Since a crash usually has a stack trace logged. In this case, it looks like a case of high volume writes. Here's how to handle this: https://typesense.org/docs/guide/syncing-data-into-typesense.html#handling-http-503s
k
Yes, this is not a crash.
queued_writes: 2153
This indicates that the node is catching up on 2153 write log entries. Once this value exceeds
healthy-read-lag
the server starts returning 503 status code because the data is stale.
g
I have done most of those, increased write healthy lag, and even then when looking at /stats.json typesense is able to cope with the pressure. The thing is, once it gets into this state, even after 12h it never heals back.
CPU keeps crunching as if it was always tyring to reindex from the state logs? /stats does not show
pending_write_batches
Copy code
{
  "delete_latency_ms": 0,
  "delete_requests_per_second": 0,
  "import_latency_ms": 0,
  "import_requests_per_second": 0,
  "latency_ms": {},
  "overloaded_requests_per_second": 0,
  "pending_write_batches": 0,
  "requests_per_second": {
    "GET /collections": 0.1
  },
  "search_latency_ms": 0,
  "search_requests_per_second": 0,
  "total_requests_per_second": 0.1,
  "write_latency_ms": 0,
  "write_requests_per_second": 0
}
I will leave it for more hours and see.
k
That count doesn't decrease? What about other numbers like local sequence number
g
Copy code
docker service logs app_search  -f | grep queued_writes
Local sequence never decreases
Copy code
ying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 138171202
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:40:59.644800   192 raft_server.h:60] Peer refresh succeeded!
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:09.645870   166 raft_server.cpp:564] Term: 6, last_index index: 29216, committed_index: 29216, known_applied_index: 29216, applying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 138171202
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:09.646028   192 raft_server.h:60] Peer refresh succeeded!
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:19.647183   166 raft_server.cpp:564] Term: 6, last_index index: 29216, committed_index: 29216, known_applied_index: 29216, applying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 138171202
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:19.647348   192 raft_server.h:60] Peer refresh succeeded!
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:21.810331   167 batched_indexer.cpp:285] Running GC for aborted requests, req map size: 0
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:29.648619   166 raft_server.cpp:564] Term: 6, last_index index: 29216, committed_index: 29216, known_applied_index: 29216, applying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 138171202
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:29.648821   192 raft_server.h:60] Peer refresh succeeded!
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:39.649920   166 raft_server.cpp:564] Term: 6, last_index index: 29216, committed_index: 29216, known_applied_index: 29216, applying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 138171202
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:39.650084   192 raft_server.h:60] Peer refresh succeeded!
app_search.1.8ptgu83qil7w@formalist    | I20231127 05:41:49.651175   166 raft_server.cpp:564] Term: 6, last_index index: 29216, committed_index: 29216, known_applied_index: 29216, applying_index: 0, queued_writes: 0, pending_queue_size: 0, local_sequence: 138171202
k
Hmm then it's somehow stuck. If you are able to share the data directory we might be able to take a look. Otherwise difficult to identify what's going wrong.
g
I can share those nice jsonl batch, its public data. Let me prepare that on a cloud storage along with the python code doing the indexing.
k
You can actually zip up the data directory and share that. That will be easier to debug.
šŸ‘Œ 1
Stop docker, zip the data directory and share that.
g
šŸ‘‰ Archive here 11GB tar.gz, folders
meta
db
models
state
are at the root of the archive. https://storage.googleapis.com/sg_public_usa/typesense_volume_fail_greg_20231127.tar.gz
Current compose if needed:
Copy code
search:
    image: typesense/typesense:0.25.1
    restart: on-failure
    volumes:
      - /mnt/disks/typesense-data:/data
    command: '--data-dir /data --api-key=${TYPESENSE_API_KEY} --num-documents-parallel-load=5000 --enable-cors  --healthy-read-lag=5000 --healthy-write-lag=10000 --cors-domains=http://localhost:8000'
    labels:
      - "traefik.enable=true"
      - traefik.http.services.search.loadbalancer.server.port=8108
    networks:
      - traefik-public
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - ....
    deploy:
      resources:
        limits:
          memory: 8G
Interesting, post docker restart fixed it....
It still makes the solo node mode unusable for now.
k
Is it reproduceable often with the same dataset if you run the import again?
g
Yes, after a few reindex it always happens, its a matter of time ~ 40-80min
k
Can you please try against 0.25.2.rc10? We've fixed some edge cases in that and would like to see if it helps here.
g
Testing now, I am also going to spawn a dedicated machine outside of gcloud to test.
It did not help, same issue. Regarding the new test node with 64GB ram and 12CPU. I push a few 100k documents on 3 collections, then hit a fs limit, edited the levels restart ed typense and: • health is ok • stats is stuck on
"pending_write_batches": 4541,
• Timeout on collection deletion • cant push more data (probably the write health limit) loop
Copy code
I20231127 12:54:44.852870 10689 raft_server.h:60] Peer refresh succeeded!
I20231127 12:54:54.857040 10648 raft_server.cpp:564] Term: 6, last_index index: 5140, committed_index: 5140, known_applied_index: 5140, applying_index: 0, queued_writes: 4541, pending_queue_size: 0, local_sequence: 1034501
I20231127 12:54:54.857234 10687 raft_server.h:60] Peer refresh succeeded!
I20231127 12:55:03.539821 10649 batched_indexer.cpp:285] Running GC for aborted requests, req map size: 1
I20231127 12:55:04.861107 10648 raft_server.cpp:564] Term: 6, last_index index: 5140, committed_index: 5140, known_applied_index: 5140, applying_index: 0, queued_writes: 4541, pending_queue_size: 0, local_sequence: 1034501
I20231127 12:55:04.861287 10693 raft_server.h:60] Peer refresh succeeded!
I20231127 12:55:14.864997 10648 raft_server.cpp:564] Term: 6, last_index index: 5140, committed_index: 5140, known_applied_index: 5140, applying_index: 0, queued_writes: 4541, pending_queue_size: 0, local_sequence: 1034501
I20231127 12:55:14.865191 10689 raft_server.h:60] Peer refresh succeeded!
@Kishore Nallan I will gladly share an ssh key. Its a test machine.
k
1. Can you elaborate how you are pushing the data? Are you sending everything at one shot or using a client to push updates? If so does the program pushing updates single threaded or you push parallely? 2. If you restart the Typesense server right after this problem occurs, does it resolve or it gets stuck in some other place?
g
I am pushing the data using 10k documents Payloads with 6 processes (Python multicore)
Copy code
responses = client.collections[collection_name].documents.import_(
        documents, {"action": "upsert", "dirty_values": "drop"}
    )
Copy code
@backoff.on_exception(
    backoff.expo,
    (requests.exceptions.RequestException, typesense.exceptions.TypesenseClientError),
    max_tries=5,
)
def process_file_batch(file_paths, client, collection_name):
    documents = []
    for filename in file_paths:
        with open(filename, "r") as file:
            for line in file:
                document = json.loads(line)
                # convert any None to empty string
                for key, value in document.items():
                    if value is None:
                        document[key] = ""

                # add phonetic name
                document["legal_name_phonetic"] = soundex(document["legal_name"]) if document["legal_name"] else ""
                documents.append(document)
    if not documents:
        return 0

    # Index documents to Typesense
    responses = client.collections[collection_name].documents.import_(
        documents, {"action": "upsert", "dirty_values": "drop"}
    )

    for response in responses:
        if not response["success"]:
            print("Error importing documents:", response)

    return len(documents)
I can try single threaded.
k
We definitely want to get to the bottom of the issue but temporarily to see if it helps, try sending data in a single thread and add a sleep + backoff if the server returns 503. Happy to debug further based on how that works.
g
Ok will try a few reindex this way šŸ¤ž
k
With the multi threaded indexing, how long after indexing does it get stuck this way?
g
It can get stuck for ever or a few hours. It is very slow to get back at the 32M docs (maybe I can change some settings to push docs per thread). Sometimes even when it shows that it got all the documents loaded it does not get back to an healthy state. I am starting over clean now with one worker.
k
No I mean how long after starting multi threaded indexing does the queued_writes number stop moving?
g
At least 30minutes, its kind of random and may require several re-index rounds on my side.
k
Ok
g
Curently importing
Copy code
"import_latency_ms": 7732.0,
	"import_requests_per_second": 0.1,
	"latency_ms": {
		"GET /health": 0.0,
		"GET /stats.json": 0.0,
		"POST /collections/companiesfr_alias_27112023_55128/documents/import": 7732.0
	},
This means that typesense takes 7s to receive the Payload (JSON) or that it take is 7seconds to ingest those documents?
k
Total 7s end of end including indexing because the API is synchronous. When it returns you are guaranteed that the docs are indexed.
šŸ‘Œ 1
g
First round āœ… I am going to restart the instance to see how long it needs to become healthy again.
Copy code
[
	{
		"created_at": 1701094570,
		"default_sorting_field": "",
		"enable_nested_fields": true,
		"fields": [
           ...
		],
		"name": "companiesfr_alias_27112023_55128",
		"num_documents": 26126793,
		"symbols_to_index": [],
		"token_separators": []
	}
]
Toolk 20min (1min per million docs~)
Copy code
app_search.1.s1lkz6iqyfmr@formalist    | I20231127 16:57:32.738953   172 collection_manager.cpp:207] Loading upto 16 collections in parallel, 5000 documents at a time.
So far so good, doing more single threaded reindex.
k
Good to hear. So I think the issue you faced earlier could be happening only when concurrent writes are happening to the same collection. To help us identify this issue, can you please share the following: 1. The collection schema 2. The dataset in the format that your Python script consumes 3. The python script that indexes the collection in parallel With this, we will be able to run the indexing as you did earlier so we can reproduce the issue and see what happens in detail on a debug build.
g
Copy code
def create_companiesfr_collection(client, collection_name: str = "companiesfr"):
    schema = {
        "name": collection_name,
        "enable_nested_fields": True,
        "fields": [
            {"name": "siren", "type": "string"},
            {"name": "legal_name", "locale": "fr", "type": "string"},
            {"name": "legal_name_phonetic", "locale": "fr", "type": "string"},
            {"name": "entity_type", "type": "string", "facet": True},
        ],
    }
Archive of
export_data
folder needed (Raw documents): https://storage.googleapis.com/sg_public_usa/export_data.gzip Python script to launch the work: https://storage.googleapis.com/sg_public_usa/typesense_manager.py Set NUMWOKERS to
n
Set HOST to typesense server python
typesense_manager.py
Select option
5
.
k
Thank you, will try this and get back to you!
I'm having trouble extracting the gzip. Can you please share a tar gz or zip file?
Ignore, I was able to extract
@Greg Tappero What
BATCH_SIZE
value did you use when you ran on multiple processes?
(this variable on the python script shared above)
g
4 or 6
k
I was not able to reproduce this stuck issue. Tried 4 times and it worked fine on all cases. The indexing script finished successfully and Typesense server had a
0
for queued writes etc. so nothing was stuck. I wonder if the issue you faced was because of running into some limits like open files (ulimit) etc.
g
Hi Kishore, thank you for reporting that. Strange, I could not see any ulimit errors. Since I was running out of time I moved to Meilisearch but I will eventually revisit Typesense.
k
Sounds good.