You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by jorgeeflorez <jo...@gmail.com> on 2021/02/03 17:17:19 UTC

Mongo DB name max length

Hi all, I hope you are all doing well...

According to the documentation
<https://docs.mongodb.com/v3.6/reference/limits/>, in MongoDB I can create
a database whose name is up to 64 characters. When I try to connect to a
repository (Oak 1.12.0) that does not exist and use a db name with 64
characters I am getting:

Exception in thread "main" com.mongodb.MongoCommandException: Command
failed with error 73 (InvalidNamespace): 'Invalid database name:
'repository123456789012345678901234567890123456789012345678901234'' on
server 192.168.200.1:37017. The full response is { "ok" : 0.0, "errmsg" :
"Invalid database name:
'repository123456789012345678901234567890123456789012345678901234'", "code"
: 73, "codeName" : "InvalidNamespace" }

After some debugging, I found out that the driver appends .$cmd to the
database name, and with that, exceeds the 64 limit. If I use a db name with
63 it appears to work.

My test class has the following :

    public static void main(String[] args) throws RepositoryException {
        String repositoryName =
"repository123456789012345678901234567890123456789012345678901234";
        OakFileDataStore fileDataStore = new OakFileDataStore();
        fileDataStore.setMinRecordLength(0);
        File repositoryFolder = new File("E:\\repos", repositoryName);
        fileDataStore.init(repositoryFolder.getAbsolutePath());

        DataStoreBlobStore dsbs = new DataStoreBlobStore(fileDataStore);

        MongoDocumentNodeStoreBuilder builder = new
MongoDocumentNodeStoreBuilder().
                setMongoDB("mongodb://forest:forest@192.168.200.1:37017",
repositoryName, 16).
                setClusterId(123456).
                setAsyncDelay(1000).
                setBlobStore(dsbs);

        DocumentNodeStore docStore = builder.build();

        Oak oak = new Oak(docStore);

        LuceneIndexProvider luceneProvider = new LuceneIndexProvider();

        Jcr jcr = new Jcr(oak)
                .with(new LuceneIndexEditorProvider())
                .with((QueryIndexProvider) luceneProvider)
                .with((Observer) luceneProvider)
                .withAsyncIndexing();


        Repository repository = jcr.createRepository();
        RepositoryImpl repImpl = (RepositoryImpl) repository;
        Session session = null;
        try {
            session = repImpl.login(new SimpleCredentials("admin",
"admin".toCharArray()), null, new HashMap<String, Object>());

            Node root = session.getRootNode();
            System.out.println(root.getPath());
        }
        finally {
            if(session != null) {
                session.logout();
            }

            repImpl.shutdown();
            docStore.dispose();
        }
    }

My question is: is there another way to "create" the database having 64
characters? or should I establish 63 (or maybe less) as the limit for db
names?

Thanks.

Regards.

Jorge Flórez

Re: Mongo DB name max length

Posted by jorgeeflorez <jo...@gmail.com>.
Hi Marcel, thank you for your reply.

You could try creating the database before starting Oak.
>

I am not sure what you mean. We assume the database is created when we
login to the repository the first time. Anyway, I think we probably will
let the user define the database name up to 50 characters, it is long
enough I believe.

Regards.
Jorge Flórez


El vie, 5 feb 2021 a las 4:37, Marcel Reutegger (<mr...@adobe.com.invalid>)
escribió:

> Hi,
>
> On 03.02.21, 18:17, "jorgeeflorez" <jo...@gmail.com> wrote:
> > My question is: is there another way to "create" the database having 64
> > characters? or should I establish 63 (or maybe less) as the limit for db
> > names?
>
> You could try creating the database before starting Oak. Otherwise it may
> also be a flaw in the driver and worth a JIRA ticket with MongoDB.
>
> https://jira.mongodb.org/browse/JAVA
>
> Regards
>  Marcel
>
>

Re: Mongo DB name max length

Posted by Marcel Reutegger <mr...@adobe.com.INVALID>.
Hi,

On 03.02.21, 18:17, "jorgeeflorez" <jo...@gmail.com> wrote:
> My question is: is there another way to "create" the database having 64
> characters? or should I establish 63 (or maybe less) as the limit for db
> names?

You could try creating the database before starting Oak. Otherwise it may
also be a flaw in the driver and worth a JIRA ticket with MongoDB.

https://jira.mongodb.org/browse/JAVA

Regards
 Marcel