Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 1a36b74

Browse files
committed
PHP-1510: Fix assertions for re-routed unacknowledged writes
Stream notifications cannot be used to assert the write concern of unacknowledged writes, since they are routed through legacy opcodes instead of write commands. Use MongoLog to assert that no GLE is issued for these writes.
1 parent bb9fc90 commit 1a36b74

File tree

2 files changed

+20
-84
lines changed

2 files changed

+20
-84
lines changed

tests/standalone/mongoclient-connection-options-fsync-2.6.phpt

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ dump_writeConcern($mn);
4747

4848
echo "Setting it to false, per-query, and w=0 to force no-gle\n";
4949
$doc = array("doc" => "ument");
50+
printLogs(MongoLog::IO, MongoLog::FINE, '/is_gle_op/');
5051
$mc->test->bug572->insert($doc, array("fsync" => false, "w" => 0));
51-
dump_writeConcern($mn);
5252
$mc->test->bug572->update(array("_id" => $doc["_id"]), array("updated" => "doc"), array("fsync" => false, "w" => 0));
53-
dump_writeConcern($mn);
5453
$mc->test->bug572->remove(array("_id" => $doc["_id"]), array("fsync" => false, "w" => 0));
55-
dump_writeConcern($mn);
54+
MongoLog::setLevel(MongoLog::NONE);
5655

5756
$mc = new MongoClient($host, array("fsync" => false), array("context" => $ctx));
5857

@@ -78,12 +77,11 @@ $mc = new MongoClient($host, array("fsync" => false, "w" => 0), array("context"
7877

7978
echo "Fsync disabled by default, and gle\n";
8079
$doc = array("doc" => "ument");
80+
printLogs(MongoLog::IO, MongoLog::FINE, '/is_gle_op/');
8181
$mc->test->bug572->insert($doc);
82-
dump_writeConcern($mn);
8382
$mc->test->bug572->update(array("_id" => $doc["_id"]), array("updated" => "doc"));
84-
dump_writeConcern($mn);
8583
$mc->test->bug572->remove(array("_id" => $doc["_id"]));
86-
dump_writeConcern($mn);
84+
MongoLog::setLevel(MongoLog::NONE);
8785

8886
echo "Setting it to true, per-query, with gle=0\n";
8987
$doc = array("doc" => "ument");
@@ -135,24 +133,9 @@ array(2) {
135133
int(1)
136134
}
137135
Setting it to false, per-query, and w=0 to force no-gle
138-
array(2) {
139-
["fsync"]=>
140-
bool(false)
141-
["w"]=>
142-
int(0)
143-
}
144-
array(2) {
145-
["fsync"]=>
146-
bool(false)
147-
["w"]=>
148-
int(0)
149-
}
150-
array(2) {
151-
["fsync"]=>
152-
bool(false)
153-
["w"]=>
154-
int(0)
155-
}
136+
is_gle_op: no
137+
is_gle_op: no
138+
is_gle_op: no
156139
Fsync disabled by default
157140
array(2) {
158141
["fsync"]=>
@@ -192,24 +175,9 @@ array(2) {
192175
int(1)
193176
}
194177
Fsync disabled by default, and gle
195-
array(2) {
196-
["fsync"]=>
197-
bool(false)
198-
["w"]=>
199-
int(0)
200-
}
201-
array(2) {
202-
["fsync"]=>
203-
bool(false)
204-
["w"]=>
205-
int(0)
206-
}
207-
array(2) {
208-
["fsync"]=>
209-
bool(false)
210-
["w"]=>
211-
int(0)
212-
}
178+
is_gle_op: no
179+
is_gle_op: no
180+
is_gle_op: no
213181
Setting it to true, per-query, with gle=0
214182
array(2) {
215183
["fsync"]=>

tests/standalone/mongoclient-connection-options-journal-2.6.phpt

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ dump_writeConcern($mn);
4848

4949
echo "Setting it to false, per-query, and w=0 to force no-gle\n";
5050
$doc = array("doc" => "ument");
51+
printLogs(MongoLog::IO, MongoLog::FINE, '/is_gle_op/');
5152
$mc->test->bug572->insert($doc, array("j" => false, "w" => 0));
52-
dump_writeConcern($mn);
5353
$mc->test->bug572->update(array("_id" => $doc["_id"]), array("updated" => "doc"), array("j" => false, "w" => 0));
54-
dump_writeConcern($mn);
5554
$mc->test->bug572->remove(array("_id" => $doc["_id"]), array("j" => false, "w" => 0));
56-
dump_writeConcern($mn);
55+
MongoLog::setLevel(MongoLog::NONE);
5756

5857
$mc = new MongoClient($host, array("journal" => false), array("context" => $ctx));
5958

@@ -79,12 +78,11 @@ $mc = new MongoClient($host, array("journal" => false, "w" => 0), array("context
7978

8079
echo "journal disabled by default, and gle\n";
8180
$doc = array("doc" => "ument");
81+
printLogs(MongoLog::IO, MongoLog::FINE, '/is_gle_op/');
8282
$mc->test->bug572->insert($doc);
83-
dump_writeConcern($mn);
8483
$mc->test->bug572->update(array("_id" => $doc["_id"]), array("updated" => "doc"));
85-
dump_writeConcern($mn);
8684
$mc->test->bug572->remove(array("_id" => $doc["_id"]));
87-
dump_writeConcern($mn);
85+
MongoLog::setLevel(MongoLog::NONE);
8886

8987
echo "Setting it to true, per-query, with gle=0\n";
9088
$doc = array("doc" => "ument");
@@ -136,24 +134,9 @@ array(2) {
136134
int(1)
137135
}
138136
Setting it to false, per-query, and w=0 to force no-gle
139-
array(2) {
140-
["j"]=>
141-
bool(false)
142-
["w"]=>
143-
int(0)
144-
}
145-
array(2) {
146-
["j"]=>
147-
bool(false)
148-
["w"]=>
149-
int(0)
150-
}
151-
array(2) {
152-
["j"]=>
153-
bool(false)
154-
["w"]=>
155-
int(0)
156-
}
137+
is_gle_op: no
138+
is_gle_op: no
139+
is_gle_op: no
157140
journal disabled by default
158141
array(2) {
159142
["j"]=>
@@ -193,24 +176,9 @@ array(2) {
193176
int(1)
194177
}
195178
journal disabled by default, and gle
196-
array(2) {
197-
["j"]=>
198-
bool(false)
199-
["w"]=>
200-
int(0)
201-
}
202-
array(2) {
203-
["j"]=>
204-
bool(false)
205-
["w"]=>
206-
int(0)
207-
}
208-
array(2) {
209-
["j"]=>
210-
bool(false)
211-
["w"]=>
212-
int(0)
213-
}
179+
is_gle_op: no
180+
is_gle_op: no
181+
is_gle_op: no
214182
Setting it to true, per-query, with gle=0
215183
array(2) {
216184
["j"]=>

0 commit comments

Comments
 (0)