New analytics rule gets deleted when you view the rule in the UI after docker restart
PS222407 opened this issue · 3 comments
Describe the bug
It seems like when you create a rule, restart the docker container and view the new rule in the UI before using shell it gets deleted. I think only when source and destination are the same collection but I could not verify that bit for sure.
To Reproduce
Steps to reproduce the behavior:
- docker-compose.yml
services:
typesense:
image: typesense/typesense:27.0.rc29
container_name: test-typesense
restart: on-failure
volumes:
- ./typesense-data-dir:/data
ports:
- 8108:8108
command: '--data-dir /data --api-key=xyz --enable-cors --cors-domains=http://localhost:8188 --enable-search-analytics=true --analytics-dir=/data/analytics --analytics-flush-interval=60'
typesense_dashboard:
image: ghcr.io/bfritscher/typesense-dashboard:latest
container_name: test-typesense_dashboard
restart: on-failure
volumes:
- ./typesense-dashboard/config.json:/srv/config.json
ports:
- 8188:80
docker-compose up -d
2. create collection
curl "http://localhost:8108/collections" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"name": "product_variants",
"fields": [
{"name": "name", "type": "string" },
{"name": "popularity", "type": "int32" }
],
"default_sorting_field": "popularity"
}'
- insert a document
curl "http://localhost:8108/collections/product_variants/documents" -X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"id": "1",
"name": "First test product",
"popularity": 0
}'
- create a rule
curl -k "http://localhost:8108/analytics/rules" \
-X POST \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"name": "product_variants_popularity",
"type": "counter",
"params": {
"source": {
"collections": ["product_variants"],
"events": [
{"type": "click", "weight": 1, "name": "product_variants_click_event"}
]
},
"destination": {
"collection": "product_variants",
"counter_field": "popularity"
}
}
}'
- restart docker containers
docker-compose down && docker-compose up -d
Expected behavior
It should display the earlier created rule.
Environment (please complete the following information):
- Application mode: Web
- OS: [Ubuntu 24.04 in WSL2 on Windows 11]
- Browser: [chrome]
- Version: [1.9.1]
- Typesense Server version: [27.0.rc29 or 26.0]
Hi thanks for your report. Unfortunately I am unable to reproduce the situation if it restart docker and refresh the UI, I do see the rule. Your instructions are missing the collection. I created a basic collection
The UI code does use the standard API and does not upsert or delete a rule on loading.
If you are meaning that the analytics rules tab is completley disable that could mean that there is a bug in the detection if the feature is available on the server. The UI tries to query and rules and if the server replies with an error, it disables the tab.
Thanks for your fast reply.
Yes sorry I forgot to paste the create collection step, I added it now. Its weird that you dont get the same issue, I will look further into it to get more details on when and why this happens. I do see that the source collection(s) is empty but thats also the case when I check it via api.
The tab is not disabled, I do see older rules listed, only just newly added ones are not displaying.
I tried it with the steps I gave to reproduce another 10 times. It works 50% of the time. I really have no idea what causes this problem but I dont think the UI is the problem which I initially thought so this issue can propably be closed.