-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop a capped collection #1745
Comments
From what I see in MongoDB documentation |
As discussed in Document Deletion, individual documents cannot be removed but there should be no issue dropping the collection itself. Best I can tell, when SchemaCollection drops a document collection, it ultimately invokes |
Versions: Document:
The command I execute and that failed:
The three called failed: dropDocumentCollection, dropDocumentDatabase or dropDatabases with message: cannot remove from a capped collection |
I'm unable to reproduce with the following environment and test case:
<?php
namespace Doctrine\ODM\MongoDB\Tests\Functional;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
class GH1745Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
public function testCreateCollectionsCapped()
{
$sm = $this->dm->getSchemaManager();
$sm->dropDocumentCollection(GH1745Document::class);
$sm->createDocumentCollection(GH1745Document::class);
foreach (['a', 'b', 'c'] as $username) {
$document = new GH1745Document;
$document->username = $username;
$this->dm->persist($document);
}
$this->dm->flush();
$coll = $this->dm->getDocumentCollection(GH1745Document::class);
$this->assertCount(3, $coll->find()->toArray());
exit;
$this->dm->getSchemaManager()->dropDocumentCollection(GH1745Document::class);
$this->dm->getSchemaManager()->dropDocumentDatabase(GH1745Document::class);
$this->dm->getSchemaManager()->dropDatabases();
}
}
/**
* @ODM\Document(collection={
* "name"="GH1745Document",
* "capped"=true,
* "size"=1073741824,
* "max"=3000000
* })
*/
class GH1745Document
{
/** @ODM\Id */
public $id;
/** @ODM\Field(type="string") */
public $username;
} If I interrupt the script with
The error message "cannot remove from a capped collection" evidently originates from the server and appears twice in its code base:
The message templating in
That said, I still see no evidence of
What is the complete exception (message and integer code) and full back trace? On the off chance that contains some useful information, my next question is going to be why wasn't that included in the original post. |
Thank you for your work. |
Are you still able to share the complete exception and back trace, or are we never going to get to see that? I was very much looking forward to seeing that, as it'd have cleared up a lot of questions.
If the MongoDB collection was not capped, I can think of no reason for "cannot remove from a capped collection" to appear. This issue is missing too many details. It was helpful for you to provide version information in #1745 (comment), but ideally that should appear in the original post. Additionally, you should provide details about the MongoDB deployment, connection URI/options, and above all else: the exception message and back trace. Please keep this in mind in the future.
AFAIK, the collection options in ODM are only used by the SchemaManager classes and it is your responsibility to run the schema commands. If you create new objects for a model class that defines While ODM theoretically could check for the existence of a collection (e.g. call the equivalent of |
I'm sorry, I haven't more logs when the erreur occur and the collection was drop with the database after I rename it and try again the command :(
|
According to From the
The trace cuts off before we see the response to the I have no idea what Thinking ahead, it seems possible that you may be trying to manage the schema of this log collection from within the same app that is actively logging while doing so. If so, I'd suggest doing this outside of the application (e.g. use the MongoDB shell) or ensure that the console command in question disables logging completely. Considering Monolog uses the extension/library directly to insert log messages, mapping them in ODM sounds like over-architecting. |
The logs until the error:
I save logs directly from Monolog to MongoDB. |
Is ACMonologBundle an open-source package, or is this your private bundle? The most recent
Assuming those three commands are all executed from a command class in ACMonologBundle, I don't understand why the code is attempting to delete documents before dropping the collection. Have you identified the source of this Assuming the code example in #1745 (comment) was taken from ACMonologBundle, I can tell you with certainty that none of the ODM SchemaManager methods should be executing a
Were you able to narrow down the break to a specific update of a single package/extension, or was this break only observed after updating multiple things in one shot? |
Closing as nothing happened here in 5 years 👼 |
Using drop functions from Doctrine\ODM\MongoDB\SchemaManager on a capped collection return now an error with mongoDB 3.6:
So how to remove a capped collection ?
Thank you
The text was updated successfully, but these errors were encountered: