MongoDB Haskell driver, including patch for MongoDB v.6.* authentication with SCRAM-SHA256
Find a file
Arnaud Spiwack bd25f8bee3 Unmask the forked thread in newPipeline
The `newPipeline` function, used as part of `connect`, forks a
listener thread. Before this commit, the thread is forked with
`forkFinally`, where the thread action is run in the same mask as the
parent thread. The thread is then killed by a `killThread` when
closing a connection.

This is typically not a problem if the mask is “masked” (or,
obviously, “unmasked”), because the listener is generally blocked on a
channel at some time or other, and therefore will accept the
asynchronous exception thrown by `killThread`, and terminate.

However, if the mask is “masked uninterruptible”, then the listener
definitely doesn't receive asynchronous exceptions, and the
`killThread` calls hangs, and never returns.

One should probably never call `connect` in a “masked uninterruptible”
action. However, it sounds better to protect the mongoDB library
against the user accidentally doing so than to add a big warning
saying that calling `connect` in “masked uninterruptible” will cause
the program to hang down the line.

Therefore, this commit uses `forkIOWithUnmask`, in order to run the
thread action always in an “unmasked” state. In which case we can be
sure that we can always kill the listener thread regardless of the
client code.
2019-10-29 09:49:44 +01:00
Database Unmask the forked thread in newPipeline 2019-10-29 09:49:44 +01:00
doc Fix documentation for access function 2017-05-06 23:55:27 -07:00
test Test for non multi update 2017-05-29 16:34:35 -07:00
.gitignore Add .stack-work to .gitignore. 2019-05-29 16:30:24 -07:00
.travis.yml Force reinstalls when installing dependencies 2019-02-26 18:41:38 -08:00
Benchmark.hs Increase benchmark size for better resolution 2016-04-30 14:08:19 -07:00
CHANGELOG.md Bump version 2019-06-14 21:21:51 -07:00
docker-compose.yml Add aggregate that returns Cursor 2018-02-08 22:18:58 -08:00
LICENSE Add license file 2010-06-28 20:24:23 -04:00
mongoDB.cabal Bump version 2019-06-14 21:21:51 -07:00
README.md Add docker-compose file for dev environment 2017-04-09 11:16:06 -07:00
reattach.sh Add docker-compose file for dev environment 2017-04-09 11:16:06 -07:00
Setup.lhs User WriteFailure instead of WriteError 2017-04-09 20:43:54 -07:00
stack-ghc80.yaml Add module Database.MongoDB.Internal.Network. 2019-05-29 18:02:37 -07:00
stack-ghc82.yaml Add module Database.MongoDB.Internal.Network. 2019-05-29 18:02:37 -07:00
stack-ghc84.yaml Add module Database.MongoDB.Internal.Network. 2019-05-29 18:02:37 -07:00
stack-ghc86-network3.yaml Add module Database.MongoDB.Internal.Network. 2019-05-29 18:02:37 -07:00
stack-ghc86.yaml Add module Database.MongoDB.Internal.Network. 2019-05-29 18:02:37 -07:00

This is the Haskell MongoDB driver (client). MongoDB is a free, scalable, fast, document database management system. This driver lets you connect to a MongoDB server, and update and query its data. It also lets you do adminstrative tasks, like create an index or look at performance statistics.

Join the chat at https://gitter.im/mongodb-haskell/mongodb Build Status

Documentation

Dev Environment

It's important for this library to be tested with various versions of mongodb server and with different ghc versions. In order to achieve this we use docker containers and docker-compose. This repository contains two files: docker-compose.yml and reattach.sh.

Docker compose file describes two containers.

One container is for running mongodb server. If you want a different version of mongodb server you need to change the tag of mongo image in the docker-compose.yml. In order to start your mongodb server you need to run:

docker-compose up -d mongodb

In order to stop your containers without loosing the data inside of it:

docker-compose stop mongodb

Restart:

docker-compose start mongodb

If you want to remove the mongodb container and start from scratch then:

docker-compose stop mongodb
docker-compose rm mongodb
docker-compose up -d mongodb

The other container is for compiling your code. By specifying the tag of the image you can change the version of ghc you will be using. If you never started this container then you need:

docker-compose run mongodb-haskell

It will start the container and mount your working directory to /opt/mongodb-haskell If you exit the bash cli then the conainer will stop. In order to reattach to an old stopped container you need to run script reattach.sh. If you run docker-compose run again it will create another container and all work made by cabal will be lost. reattach.sh is a workaround for docker-compose's inability to pick up containers that exited.

When you are done with testing you need to run:

docker-compose stop mongodb

Next time you will need to do:

docker-compose start mongodb
reattach.sh

It will start your stopped container with mongodb server and pick up the stopped container with haskell.