mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-09 09:35:00 +09:00
GO-4972 archive sync detail indexation fix (#2064)
This commit is contained in:
parent
ed463a29e7
commit
1c9a3b84e4
5 changed files with 37 additions and 11 deletions
|
@ -151,9 +151,11 @@ var filesLayouts = map[model.ObjectTypeLayout]struct{}{
|
|||
|
||||
func (i *indexer) prepareSearchDocument(ctx context.Context, id string) (docs []ftsearch.SearchDoc, err error) {
|
||||
ctx = context.WithValue(ctx, metrics.CtxKeyEntrypoint, "index_fulltext")
|
||||
var fulltextSkipped bool
|
||||
err = cache.DoContext(i.picker, ctx, id, func(sb smartblock2.SmartBlock) error {
|
||||
indexDetails, _ := sb.Type().Indexable()
|
||||
if !indexDetails {
|
||||
fulltext, _, _ := sb.Type().Indexable()
|
||||
if !fulltext {
|
||||
fulltextSkipped = true
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -234,6 +236,12 @@ func (i *indexer) prepareSearchDocument(ctx context.Context, id string) (docs []
|
|||
|
||||
return nil
|
||||
})
|
||||
if fulltextSkipped {
|
||||
// todo: this should be removed. objects which is not supposed to be added to fulltext index should not be added to the queue
|
||||
// but now it happens in the ftInit that some objects still can be added to the queue
|
||||
// we need to avoid TryRemoveFromCache in this case
|
||||
return docs, nil
|
||||
}
|
||||
_, cacheErr := i.picker.TryRemoveFromCache(ctx, id)
|
||||
if cacheErr != nil {
|
||||
log.With("objectId", id).Errorf("object cache remove: %v", err)
|
||||
|
|
|
@ -142,7 +142,7 @@ func (i *spaceIndexer) index(ctx context.Context, info smartblock.DocInfo, optio
|
|||
}
|
||||
}
|
||||
|
||||
indexDetails, indexLinks := info.SmartblockType.Indexable()
|
||||
_, indexDetails, indexLinks := info.SmartblockType.Indexable()
|
||||
if !indexDetails && !indexLinks {
|
||||
return nil
|
||||
}
|
||||
|
@ -192,8 +192,11 @@ func (i *spaceIndexer) index(ctx context.Context, info smartblock.DocInfo, optio
|
|||
|
||||
if !(opts.SkipFullTextIfHeadsNotChanged && lastIndexedHash == headHashToIndex) {
|
||||
// Use component's context because ctx from parameter contains transaction
|
||||
if err := i.objectStore.AddToIndexQueue(i.runCtx, info.Id); err != nil {
|
||||
log.With("objectID", info.Id).Errorf("can't add id to index queue: %v", err)
|
||||
fulltext, _, _ := info.SmartblockType.Indexable()
|
||||
if fulltext {
|
||||
if err := i.objectStore.AddToIndexQueue(i.runCtx, info.Id); err != nil {
|
||||
log.With("objectID", info.Id).Errorf("can't add id to index queue: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -198,6 +198,7 @@ func (u *syncStatusUpdater) updateObjectDetails(syncStatusDetails *syncStatusDet
|
|||
if details == nil {
|
||||
details = domain.NewDetails()
|
||||
}
|
||||
// todo: make the checks consistent here and in setSyncDetails
|
||||
if !u.isLayoutSuitableForSyncRelations(details) {
|
||||
return details, false, nil
|
||||
}
|
||||
|
@ -223,6 +224,14 @@ func (u *syncStatusUpdater) updateObjectDetails(syncStatusDetails *syncStatusDet
|
|||
|
||||
func (u *syncStatusUpdater) setSyncDetails(sb smartblock.SmartBlock, status domain.ObjectSyncStatus, syncError domain.SyncError) error {
|
||||
if !slices.Contains(helper.SyncRelationsSmartblockTypes(), sb.Type()) {
|
||||
if sb.LocalDetails().Has(bundle.RelationKeySyncStatus) {
|
||||
// do cleanup because of previous sync relations indexation problem
|
||||
st := sb.NewState()
|
||||
st.LocalDetails().Delete(bundle.RelationKeySyncDate)
|
||||
st.LocalDetails().Delete(bundle.RelationKeySyncStatus)
|
||||
st.LocalDetails().Delete(bundle.RelationKeySyncError)
|
||||
return sb.Apply(st, smartblock.KeepInternalFlags)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
st := sb.NewState()
|
||||
|
|
|
@ -70,13 +70,19 @@ func (sbt SmartBlockType) IsOneOf(sbts ...SmartBlockType) bool {
|
|||
}
|
||||
|
||||
// Indexable determines if the object of specific type need to be proceeded by the indexer in order to appear in sets
|
||||
func (sbt SmartBlockType) Indexable() (details, outgoingLinks bool) {
|
||||
func (sbt SmartBlockType) Indexable() (fulltext, details, outgoingLinks bool) {
|
||||
switch sbt {
|
||||
case SmartBlockTypeDate, SmartBlockTypeAccountOld, SmartBlockTypeNotificationObject, SmartBlockTypeDevicesObject:
|
||||
return false, false
|
||||
return false, false, false
|
||||
case SmartBlockTypeWidget, SmartBlockTypeArchive, SmartBlockTypeHome:
|
||||
return true, false
|
||||
return false, true, false
|
||||
case SmartBlockTypeWorkspace,
|
||||
SmartBlockTypeAccountObject,
|
||||
SmartBlockTypeChatObject,
|
||||
SmartBlockTypeChatDerivedObject,
|
||||
SmartBlockTypeSpaceView:
|
||||
return false, true, true
|
||||
default:
|
||||
return true, true
|
||||
return true, true, true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ func (s *dsObjectStore) QueryFromFulltext(results []database.FulltextResult, par
|
|||
for _, res := range results {
|
||||
// Don't use spaceID because expected objects are virtual
|
||||
if sbt, err := typeprovider.SmartblockTypeFromID(res.Path.ObjectId); err == nil {
|
||||
if indexDetails, _ := sbt.Indexable(); !indexDetails && s.sourceService != nil {
|
||||
if _, indexDetails, _ := sbt.Indexable(); !indexDetails && s.sourceService != nil {
|
||||
details, err := s.sourceService.DetailsFromIdBasedSource(domain.FullID{
|
||||
ObjectID: res.Path.ObjectId,
|
||||
SpaceID: s.SpaceId(),
|
||||
|
@ -428,7 +428,7 @@ func (s *dsObjectStore) QueryByIds(ids []string) (records []database.Record, err
|
|||
for _, id := range ids {
|
||||
// Don't use spaceID because expected objects are virtual
|
||||
if sbt, err := typeprovider.SmartblockTypeFromID(id); err == nil {
|
||||
if indexDetails, _ := sbt.Indexable(); !indexDetails && s.sourceService != nil {
|
||||
if _, indexDetails, _ := sbt.Indexable(); !indexDetails && s.sourceService != nil {
|
||||
details, err := s.sourceService.DetailsFromIdBasedSource(domain.FullID{
|
||||
ObjectID: id,
|
||||
SpaceID: s.SpaceId(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue