Skip to content

Commit 331a7a1

Browse files
committed
Merge pull request #1009
2 parents 2353a56 + 8d8573e commit 331a7a1

14 files changed

+294
-14
lines changed

CONTRIBUTING.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,18 @@ If something goes awry in the test VM, you can reload it by running:
172172
make test-bootstrap
173173
```
174174

175-
## Releasing
175+
## Updating libmongoc and libbson
176176

177-
The follow steps outline the release process for a maintenance branch (e.g.
178-
releasing the `vX.Y` branch as X.Y.Z).
177+
The PHP driver uses a bundled version of libmongoc and libbson. If a new version
178+
of libmongoc is available, the submodule needs to be updated.
179+
180+
### Update libmongoc to the latest version
181+
182+
```
183+
$ cd src/libmongoc
184+
$ git fetch
185+
$ git checkout 1.15.0
186+
```
179187

180188
### Ensure libmongoc version information is correct
181189

@@ -190,6 +198,20 @@ $ make libmongoc-version-current
190198
Alternatively, the `build/calc_release_version.py` script in libmongoc can be
191199
executed directly.
192200

201+
### Test and commit your changes
202+
203+
Once you have verified that all tests pass, commit the changes to the submodule
204+
and `src/LIBMONGOC_VERSION_CURRENT`:
205+
206+
```
207+
$ git commit -m "Bump libmongoc to 1.15.0" src/LIBMONGOC_VERSION_CURRENT src/libmongoc
208+
```
209+
210+
## Releasing
211+
212+
The follow steps outline the release process for a maintenance branch (e.g.
213+
releasing the `vX.Y` branch as X.Y.Z).
214+
193215
### Ensure PHP version compatibility
194216

195217
Ensure that the extension compiles on PHP 5.6 through the latest PHP 7.x

config.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ if test "$PHP_MONGODB" != "no"; then
190190
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
191191
AC_MSG_CHECKING(for libbson)
192192
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libbson-1.0; then
193-
if $PKG_CONFIG libbson-1.0 --atleast-version 1.14.0; then
193+
if $PKG_CONFIG libbson-1.0 --atleast-version 1.15.0; then
194194
PHP_MONGODB_BSON_CFLAGS=`$PKG_CONFIG libbson-1.0 --cflags`
195195
PHP_MONGODB_BSON_LIBS=`$PKG_CONFIG libbson-1.0 --libs`
196196
PHP_MONGODB_BSON_VERSION=`$PKG_CONFIG libbson-1.0 --modversion`
197197
AC_MSG_RESULT(version $PHP_MONGODB_BSON_VERSION found)
198198
else
199-
AC_MSG_ERROR(system libbson must be upgraded to version >= 1.14.0)
199+
AC_MSG_ERROR(system libbson must be upgraded to version >= 1.15.0)
200200
fi
201201
else
202202
AC_MSG_ERROR(pkgconfig and libbson must be installed)
@@ -214,13 +214,13 @@ if test "$PHP_MONGODB" != "no"; then
214214
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
215215
AC_MSG_CHECKING(for libmongoc)
216216
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmongoc-1.0; then
217-
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.14.0; then
217+
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.15.0; then
218218
PHP_MONGODB_MONGOC_CFLAGS=`$PKG_CONFIG libmongoc-1.0 --cflags`
219219
PHP_MONGODB_MONGOC_LIBS=`$PKG_CONFIG libmongoc-1.0 --libs`
220220
PHP_MONGODB_MONGOC_VERSION=`$PKG_CONFIG libmongoc-1.0 --modversion`
221221
AC_MSG_RESULT(version $PHP_MONGODB_MONGOC_VERSION found)
222222
else
223-
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.14.0)
223+
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.15.0)
224224
fi
225225
else
226226
AC_MSG_ERROR(pkgconfig and libmongoc must be installed)

src/LIBMONGOC_VERSION_CURRENT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.15.0-20190717+gitc88b84ff38
1+
1.15.0

src/libmongoc

Submodule libmongoc updated 112 files
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
--TEST--
2+
Retryable reads: executeReadCommand is retried once
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_libmongoc_crypto(); ?>
6+
<?php skip_if_no_failcommand_failpoint(); ?>
7+
<?php skip_if_not_clean(); ?>
8+
--FILE--
9+
<?php
10+
require_once __DIR__ . "/../utils/basic.inc";
11+
12+
class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber
13+
{
14+
public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event)
15+
{
16+
printf("Command started: %s\n", $event->getCommandName());
17+
}
18+
19+
public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event)
20+
{
21+
}
22+
23+
public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event)
24+
{
25+
}
26+
}
27+
28+
$manager = new MongoDB\Driver\Manager(URI, ['retryReads' => true]);
29+
30+
$bulk = new MongoDB\Driver\BulkWrite;
31+
$bulk->insert(['x' => 1]);
32+
$bulk->insert(['x' => 2]);
33+
34+
$manager->executeBulkWrite(NS, $bulk);
35+
36+
configureFailPoint($manager, 'failCommand', ['times' => 1], ['failCommands' => ['aggregate'], 'closeConnection' => true]);
37+
38+
$observer = new Observer;
39+
MongoDB\Driver\Monitoring\addSubscriber($observer);
40+
41+
$command = new MongoDB\Driver\Command([
42+
'aggregate' => COLLECTION_NAME,
43+
'pipeline' => [
44+
['$group' => ['_id' => 1, 'n' => ['$sum' => 1]]],
45+
],
46+
'cursor' => (object) [],
47+
]);
48+
$cursor = $manager->executeReadCommand(DATABASE_NAME, $command);
49+
var_dump(iterator_to_array($cursor));
50+
51+
MongoDB\Driver\Monitoring\removeSubscriber($observer);
52+
53+
?>
54+
===DONE===
55+
<?php exit(0); ?>
56+
--EXPECTF--
57+
Command started: aggregate
58+
Command started: aggregate
59+
array(1) {
60+
[0]=>
61+
object(stdClass)#%d (2) {
62+
["_id"]=>
63+
int(1)
64+
["n"]=>
65+
int(2)
66+
}
67+
}
68+
===DONE===
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
Retryable reads: executeQuery is retried once
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_libmongoc_crypto(); ?>
6+
<?php skip_if_no_failcommand_failpoint(); ?>
7+
<?php skip_if_not_clean(); ?>
8+
--FILE--
9+
<?php
10+
require_once __DIR__ . "/../utils/basic.inc";
11+
12+
class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber
13+
{
14+
public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event)
15+
{
16+
printf("Command started: %s\n", $event->getCommandName());
17+
}
18+
19+
public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event)
20+
{
21+
}
22+
23+
public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event)
24+
{
25+
}
26+
}
27+
28+
$manager = new MongoDB\Driver\Manager(URI, ['retryReads' => true]);
29+
30+
$bulk = new MongoDB\Driver\BulkWrite;
31+
$bulk->insert(['x' => 1]);
32+
$bulk->insert(['x' => 2]);
33+
34+
$manager->executeBulkWrite(NS, $bulk);
35+
36+
configureFailPoint($manager, 'failCommand', ['times' => 1], ['failCommands' => ['find'], 'closeConnection' => true]);
37+
38+
$observer = new Observer;
39+
MongoDB\Driver\Monitoring\addSubscriber($observer);
40+
41+
$cursor = $manager->executeQuery(NS, new \MongoDB\Driver\Query(['x' => 1]));
42+
var_dump(iterator_count($cursor));
43+
44+
MongoDB\Driver\Monitoring\removeSubscriber($observer);
45+
46+
?>
47+
===DONE===
48+
<?php exit(0); ?>
49+
--EXPECT--
50+
Command started: find
51+
Command started: find
52+
int(1)
53+
===DONE===
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
--TEST--
2+
Retryable reads: executeReadCommand is not retried when retryable reads are disabled
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_libmongoc_crypto(); ?>
6+
<?php skip_if_no_failcommand_failpoint(); ?>
7+
--FILE--
8+
<?php
9+
require_once __DIR__ . "/../utils/basic.inc";
10+
11+
class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber
12+
{
13+
public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event)
14+
{
15+
printf("Command started: %s\n", $event->getCommandName());
16+
}
17+
18+
public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event)
19+
{
20+
}
21+
22+
public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event)
23+
{
24+
}
25+
}
26+
27+
$manager = new MongoDB\Driver\Manager(URI, ['retryReads' => false]);
28+
29+
configureFailPoint($manager, 'failCommand', ['times' => 1], ['failCommands' => ['aggregate'], 'closeConnection' => true]);
30+
31+
$observer = new Observer;
32+
MongoDB\Driver\Monitoring\addSubscriber($observer);
33+
34+
throws(
35+
function() use ($manager) {
36+
$command = new MongoDB\Driver\Command([
37+
'aggregate' => COLLECTION_NAME,
38+
'pipeline' => [
39+
['$group' => ['_id' => 1, 'n' => ['$sum' => 1]]],
40+
],
41+
'cursor' => (object) [],
42+
]);
43+
$manager->executeReadCommand(DATABASE_NAME, $command);
44+
},
45+
\MongoDB\Driver\Exception\ConnectionTimeoutException::class
46+
);
47+
48+
?>
49+
===DONE===
50+
<?php exit(0); ?>
51+
--EXPECT--
52+
Command started: aggregate
53+
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException
54+
===DONE===
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--TEST--
2+
Retryable reads: executeQuery is not retried when retryable reads are disabled
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_libmongoc_crypto(); ?>
6+
<?php skip_if_no_failcommand_failpoint(); ?>
7+
--FILE--
8+
<?php
9+
require_once __DIR__ . "/../utils/basic.inc";
10+
11+
class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber
12+
{
13+
public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event)
14+
{
15+
printf("Command started: %s\n", $event->getCommandName());
16+
}
17+
18+
public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event)
19+
{
20+
}
21+
22+
public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event)
23+
{
24+
}
25+
}
26+
27+
$manager = new MongoDB\Driver\Manager(URI, ['retryReads' => false]);
28+
29+
configureFailPoint($manager, 'failCommand', ['times' => 1], ['failCommands' => ['find'], 'closeConnection' => true]);
30+
31+
$observer = new Observer;
32+
MongoDB\Driver\Monitoring\addSubscriber($observer);
33+
34+
throws(
35+
function() use ($manager) {
36+
$manager->executeQuery(NS, new \MongoDB\Driver\Query(['x' => 1]));
37+
},
38+
\MongoDB\Driver\Exception\ConnectionTimeoutException::class
39+
);
40+
41+
?>
42+
===DONE===
43+
<?php exit(0); ?>
44+
--EXPECT--
45+
Command started: find
46+
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException
47+
===DONE===

tests/retryable-writes/retryable-writes-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib
3232
$observer = new TransactionIdObserver;
3333
MongoDB\Driver\Monitoring\addSubscriber($observer);
3434

35-
$manager = new MongoDB\Driver\Manager(URI, ['retryWrites' => true]);
35+
$manager = new MongoDB\Driver\Manager(URI);
3636

3737
echo "Testing deleteOne\n";
3838
$bulk = new MongoDB\Driver\BulkWrite;

tests/retryable-writes/retryable-writes-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib
3232
$observer = new TransactionIdObserver;
3333
MongoDB\Driver\Monitoring\addSubscriber($observer);
3434

35-
$manager = new MongoDB\Driver\Manager(URI, ['retryWrites' => true]);
35+
$manager = new MongoDB\Driver\Manager(URI);
3636

3737
echo "Testing multi-statement bulk write (ordered=true)\n";
3838
$bulk = new MongoDB\Driver\BulkWrite(['ordered' => true]);

tests/retryable-writes/retryable-writes-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib
3232
$observer = new TransactionIdObserver;
3333
MongoDB\Driver\Monitoring\addSubscriber($observer);
3434

35-
$manager = new MongoDB\Driver\Manager(URI, ['retryWrites' => true]);
35+
$manager = new MongoDB\Driver\Manager(URI);
3636

3737
echo "Testing deleteMany\n";
3838
$bulk = new MongoDB\Driver\BulkWrite;

tests/retryable-writes/retryable-writes-004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib
3232
$observer = new TransactionIdObserver;
3333
MongoDB\Driver\Monitoring\addSubscriber($observer);
3434

35-
$manager = new MongoDB\Driver\Manager(URI, ['retryWrites' => true]);
35+
$manager = new MongoDB\Driver\Manager(URI);
3636
$writeConcern = new MongoDB\Driver\WriteConcern(0);
3737

3838
echo "Testing unacknowledged deleteOne\n";

tests/retryable-writes/retryable-writes-005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TransactionIdObserver implements MongoDB\Driver\Monitoring\CommandSubscrib
3232
$observer = new TransactionIdObserver;
3333
MongoDB\Driver\Monitoring\addSubscriber($observer);
3434

35-
$manager = new MongoDB\Driver\Manager(URI, ['retryWrites' => true]);
35+
$manager = new MongoDB\Driver\Manager(URI);
3636
$command = new MongoDB\Driver\Command([
3737
'findAndModify' => COLLECTION_NAME,
3838
'query' => ['x' => 1],
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Retryable writes: actionable error message when using retryable writes on unsupported storage engines
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_libmongoc_crypto(); ?>
6+
<?php skip_if_not_server_storage_engine('mmapv1'); ?>
7+
<?php skip_if_not_replica_set(); ?>
8+
<?php skip_if_server_version('<', '3.6'); ?>
9+
<?php skip_if_not_clean(); ?>
10+
--FILE--
11+
<?php
12+
require_once __DIR__ . "/../utils/basic.inc";
13+
14+
$manager = new MongoDB\Driver\Manager(URI);
15+
$session = $manager->startSession();
16+
17+
echo throws(
18+
function() use ($manager, $session) {
19+
$command = new MongoDB\Driver\Command([
20+
'findAndModify' => COLLECTION_NAME,
21+
'query' => ['x' => 1],
22+
'update' => ['$inc' => ['x' => 1]],
23+
]);
24+
$manager->executeReadWriteCommand(DATABASE_NAME, $command, ['session' => $session]);
25+
},
26+
\MongoDB\Driver\Exception\CommandException::class
27+
);
28+
echo "\n";
29+
30+
?>
31+
===DONE===
32+
<?php exit(0); ?>
33+
--EXPECT--
34+
OK: Got MongoDB\Driver\Exception\CommandException
35+
This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.
36+
===DONE===

0 commit comments

Comments
 (0)