Skip to content
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

[BUG] Unable to save timeseries document: lock for timeseries is not allowed #1005

Open
tyrantlink opened this issue Aug 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tyrantlink
Copy link

tyrantlink commented Aug 19, 2024

Describe the bug
Document.save() fails when using a timeseries collection, returning pymongo.errors.OperationFailure: Taking test.timeseries_test lock for timeseries is not allowed, full error:

{'ok': 0.0, 'errmsg': 'Taking test.timeseries_test lock for timeseries is not allowed', 'code': 166, 'codeName': 'CommandNotSupportedOnView'}

To Reproduce
with beanie==1.26.0, pymongo==4.8.0, and motor==3.5.1 on python 3.11.5

from beanie import init_beanie, Document, TimeSeriesConfig
from motor.motor_asyncio import AsyncIOMotorClient
from pydantic import Field

from datetime import datetime
from asyncio import run


MONGO_URI = ''
DATABASE = ''


class TimeSeriesTest(Document):
    ts: datetime = Field(default_factory=datetime.now)

    class Settings:
        name = 'timeseries_test'
        timeseries = TimeSeriesConfig(
            time_field='ts',
            expire_after_seconds=60
        )


async def main():
    _client = AsyncIOMotorClient(
        MONGO_URI,
        serverSelectionTimeoutMS=5000
    )[DATABASE]

    await init_beanie(_client, document_models=[TimeSeriesTest])

    ts_test = TimeSeriesTest()

    await ts_test.save()


if __name__ == '__main__':
    run(main())

Expected behavior
Document is successfully inserted

Additional context
The code above does successfully insert when not using a timeseries collection

@adeelsohailahmed adeelsohailahmed added the bug Something isn't working label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants