[ 
https://issues.apache.org/jira/browse/DIRSERVER-2314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17128406#comment-17128406
 ] 

Emmanuel Lécharny commented on DIRSERVER-2314:
----------------------------------------------

I confirm.

We enevr initialize the cache when the server is started. Should be easy to do. 
In the {{AbstractBtreePartition}} class, the {{doInit}} method does :

{code:java}
    @Override
    protected void doInit() throws LdapException
    {
        // First, inject the indexed attributes if any
        if ( ( indexedAttributes != null ) && ( !indexedAttributes.isEmpty() ) )
        {
            for ( Index index : indexedAttributes )
            {
                addIndex( index );
            }
        }

        // Now, initialize the configured index
        setupSystemIndices();
        setupUserIndices();

        aliasCache = Caffeine.newBuilder().maximumSize( cacheSize 
).expireAfterAccess( Duration.ofMinutes( 20 ) )
            .build();
...
{code}

At this point , we should feed the cache with the ALias index content.

An other solution would be to change the way we handle the cache access. 
Currently, we do things like :

{code:java}
        if ( db.getAliasCache() != null )
        {
            Dn dn = db.getAliasCache().getIfPresent( id );
            
            if ( dn != null )
            {
                return false;
            }
        }
        else if ( null != db.getAliasIndex().reverseLookup( partitionTxn, id ) )
        {
            return false;
        }
{code}

The problem is that the {{db.getAliasCache()}} will never return null, even if 
the cache is empty. We then should check in the index to see if the alias 
exist. But that would defeat the purpose of this cache, as we should assume we 
will have way more entries that are not aliases, so the cache should be a fast 
way to check that an entry is or not an alias. Checking in the index would do a 
disk access for most of the entries.

Bottom line: we should feed the cache at startup...

> Aliases don't work correctly after a restart
> --------------------------------------------
>
>                 Key: DIRSERVER-2314
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-2314
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: alias, search
>    Affects Versions: 2.0.0.AM26
>            Reporter: Kaamil Jasani
>            Priority: Major
>
> If a server that contains an alias is restarted, the alias is no longer 
> followed. This persists until the alias in question is somehow updated, 
> either by renaming, moving, or updating the target.
> It seems on initial look that this may be caused by the alias cache not being 
> rebuilt on startup. The cache seems to be empty on restart but this looks to 
> be interpreted as the alias not pointing to anything.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to