-
Notifications
You must be signed in to change notification settings - Fork 19
Persistent storage for asyncs 3 #895
Conversation
Deploying quesma with
|
| Latest commit: |
161407b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4834cc4b.quesma.pages.dev |
| Branch Preview URL: | https://persistent-storage-2.quesma.pages.dev |
61e367a to
29679c3
Compare
4ff28a1 to
576b195
Compare
61b7a7d to
76035ad
Compare
76035ad to
47229e0
Compare
| } | ||
|
|
||
| var resp *http.Response | ||
| resp, err = db.httpClient.DoRequestCheckResponseStatusOK(context.Background(), http.MethodPost, elasticsearchURL, []byte(query)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
404 is OK here, but we got:
quesma-1 | Feb 10 15:06:59.942 WRN quesma/quesma/async_search_storage/in_elasticsearch.go:72 > failed to delete old documents error="response code from Elastic is not 200 OK, but 404 Not Found"
| return err | ||
| } | ||
|
|
||
| resp, err := db.httpClient.DoRequestCheckResponseStatusOK(context.Background(), http.MethodPost, elasticsearchURL, jsonData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resp.Body should be closed.
|
|
||
| func (db *ElasticDatabaseWithEviction) Delete(id string) error { | ||
| elasticsearchURL := fmt.Sprintf("%s/_doc/%s", db.indexName, id) | ||
| resp, err := db.httpClient.DoRequestCheckResponseStatusOK(context.Background(), http.MethodDelete, elasticsearchURL, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resp.Body should be closed
| fmt.Println(query) | ||
| } | ||
|
|
||
| var resp *http.Response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resp.Body should be closed
| }` | ||
|
|
||
| var resp *http.Response | ||
| resp, err = db.httpClient.DoRequestCheckResponseStatusOK(context.Background(), http.MethodGet, elasticsearchURL, []byte(query)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resp.Body should be closed
| SizeInBytes() (int64, error) | ||
| SizeInBytesLimit() int64 | ||
| } | ||
| JSONWithSize struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSONWithSize is JSON with ID. This can be named Document
|
|
||
| func (s AsyncRequestResultStorageInMemoryFallbackElastic) Delete(id string) { | ||
| s.inMemory.Delete(id) | ||
| go s.inElasticsearch.Delete(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is risky. If there is a panic insidea s.inElasticsearch.Delete(#) whole Quesma will collapse.
We should add a recovery here:
go func() {
recovery.LogPanic()
s.inElasticsearch.Delete(id)
}()
This can called without a goroutine.
|
|
||
| func (s AsyncRequestResultStorageInMemoryFallbackElastic) evict(olderThan time.Duration) { | ||
| s.inMemory.evict(olderThan) | ||
| go s.inElasticsearch.DeleteOld(olderThan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above.
|
|
||
| func (s AsyncQueryContextStorageInMemoryFallbackElasticsearch) Store(context *AsyncQueryContext) { | ||
| s.inMemory.Store(context) | ||
| go s.inElasticsearch.Store(context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above.
|
|
||
| func (s AsyncQueryContextStorageInMemoryFallbackElasticsearch) evict(evictOlderThan time.Duration) { | ||
| s.inMemory.evict(evictOlderThan) | ||
| go s.inElasticsearch.evict(evictOlderThan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above.
|
@trzysiek please take a look, |
|
/run-it |
2 similar comments
|
/run-it |
|
/run-it |
e136961 to
161407b
Compare
|
/run-it |
|
I ran some tests, and unfortunately, it doesn’t work reliably. |
On old Kibana I don't see any regression with new storage on.