Skip to content

Commit 845e1de

Browse files
authored
CDRIVER-5953 remove deprecated write concern API (#1964)
* remove `mongoc_write_concern_get_fsync` * remove `mongoc_write_concern_set_fsync`
1 parent 8d904e5 commit 845e1de

9 files changed

+31
-182
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ Unreleased (2.0.0)
108108
* `mongoc_uri_get_service` is removed. Use `mongoc_uri_get_srv_hostname` instead.
109109
* `mongoc_uri_get_read_prefs` is removed. Use `mongoc_uri_get_read_prefs_t` instead.
110110
* `mongoc_uri_get_ssl` is removed. Use `mongoc_uri_get_tls` instead.
111+
* Deprecated write concern API is removed:
112+
* `mongoc_write_concern_get_fsync` is removed. Use `mongoc_write_concern_get_journal` instead.
113+
* `mongoc_write_concern_set_fsync` is removed. Use `mongoc_write_concern_set_journal` instead.
111114

112115
### Forwarding headers (`#include <bson.h>` and `#include <mongoc.h>`)
113116

src/libmongoc/doc/mongoc_write_concern_get_fsync.rst

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/libmongoc/doc/mongoc_write_concern_set_fsync.rst

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/libmongoc/doc/mongoc_write_concern_t.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ MONGOC_WRITE_CONCERN_W_MAJORITY (majority) Block until a write has been propaga
3434
n Block until a write has been propagated to at least ``n`` nodes in the replica set.
3535
========================================== ===============================================================================================================================================================================================================
3636

37-
Deprecations
38-
------------
39-
40-
:symbol:`mongoc_write_concern_set_fsync` is deprecated.
41-
4237
.. only:: html
4338

4439
Functions
@@ -51,7 +46,6 @@ Deprecations
5146
mongoc_write_concern_append
5247
mongoc_write_concern_copy
5348
mongoc_write_concern_destroy
54-
mongoc_write_concern_get_fsync
5549
mongoc_write_concern_get_journal
5650
mongoc_write_concern_get_w
5751
mongoc_write_concern_get_wmajority
@@ -63,7 +57,6 @@ Deprecations
6357
mongoc_write_concern_is_valid
6458
mongoc_write_concern_journal_is_set
6559
mongoc_write_concern_new
66-
mongoc_write_concern_set_fsync
6760
mongoc_write_concern_set_journal
6861
mongoc_write_concern_set_w
6962
mongoc_write_concern_set_wmajority

src/libmongoc/src/mongoc/mongoc-write-concern-private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@
2525
BSON_BEGIN_DECLS
2626

2727

28-
#define MONGOC_WRITE_CONCERN_FSYNC_DEFAULT -1
2928
#define MONGOC_WRITE_CONCERN_JOURNAL_DEFAULT -1
3029

3130

3231
struct _mongoc_write_concern_t {
33-
int8_t fsync_; /* deprecated */
3432
int8_t journal;
3533
int32_t w;
3634
int64_t wtimeout;

src/libmongoc/src/mongoc/mongoc-write-concern.c

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ mongoc_write_concern_new (void)
4242

4343
write_concern = BSON_ALIGNED_ALLOC0 (mongoc_write_concern_t);
4444
write_concern->w = MONGOC_WRITE_CONCERN_W_DEFAULT;
45-
write_concern->fsync_ = MONGOC_WRITE_CONCERN_FSYNC_DEFAULT;
4645
write_concern->journal = MONGOC_WRITE_CONCERN_JOURNAL_DEFAULT;
4746
write_concern->is_default = true;
4847

@@ -59,7 +58,6 @@ mongoc_write_concern_copy (const mongoc_write_concern_t *write_concern)
5958

6059
if (write_concern) {
6160
ret = mongoc_write_concern_new ();
62-
ret->fsync_ = write_concern->fsync_;
6361
ret->journal = write_concern->journal;
6462
ret->w = write_concern->w;
6563
ret->wtimeout = write_concern->wtimeout;
@@ -89,33 +87,6 @@ mongoc_write_concern_destroy (mongoc_write_concern_t *write_concern)
8987
}
9088

9189

92-
bool
93-
mongoc_write_concern_get_fsync (const mongoc_write_concern_t *write_concern)
94-
{
95-
BSON_ASSERT (write_concern);
96-
return (write_concern->fsync_ == true);
97-
}
98-
99-
100-
/**
101-
* mongoc_write_concern_set_fsync:
102-
* @write_concern: A mongoc_write_concern_t.
103-
* @fsync_: If the write concern requires fsync() by the server.
104-
*
105-
* Set if fsync() should be called on the server before acknowledging a
106-
* write request.
107-
*/
108-
void
109-
mongoc_write_concern_set_fsync (mongoc_write_concern_t *write_concern, bool fsync_)
110-
{
111-
BSON_ASSERT (write_concern);
112-
113-
write_concern->fsync_ = !!fsync_;
114-
write_concern->is_default = false;
115-
write_concern->frozen = false;
116-
}
117-
118-
11990
bool
12091
mongoc_write_concern_get_journal (const mongoc_write_concern_t *write_concern)
12192
{
@@ -347,10 +318,6 @@ _mongoc_write_concern_freeze (mongoc_write_concern_t *write_concern)
347318
BSON_APPEND_INT32 (compiled, "w", write_concern->w);
348319
}
349320

350-
if (write_concern->fsync_ != MONGOC_WRITE_CONCERN_FSYNC_DEFAULT) {
351-
bson_append_bool (compiled, "fsync", 5, !!write_concern->fsync_);
352-
}
353-
354321
if (write_concern->journal != MONGOC_WRITE_CONCERN_JOURNAL_DEFAULT) {
355322
bson_append_bool (compiled, "j", 1, !!write_concern->journal);
356323
}
@@ -374,7 +341,7 @@ bool
374341
mongoc_write_concern_is_acknowledged (const mongoc_write_concern_t *write_concern)
375342
{
376343
if (write_concern) {
377-
return (((write_concern->w != MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED)) || write_concern->fsync_ == true ||
344+
return (((write_concern->w != MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED)) ||
378345
mongoc_write_concern_get_journal (write_concern));
379346
}
380347
return true;
@@ -397,8 +364,8 @@ mongoc_write_concern_is_valid (const mongoc_write_concern_t *write_concern)
397364
return false;
398365
}
399366

400-
/* Journal or fsync should require acknowledgement. */
401-
if ((write_concern->fsync_ == true || mongoc_write_concern_get_journal (write_concern)) &&
367+
/* Journal should require acknowledgement. */
368+
if ((mongoc_write_concern_get_journal (write_concern)) &&
402369
(write_concern->w == MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED)) {
403370
return false;
404371
}
@@ -527,12 +494,8 @@ _mongoc_write_concern_new_from_iter (const bson_iter_t *iter, bson_error_t *erro
527494
goto fail;
528495
}
529496
} else if (BSON_ITER_IS_KEY (&inner, "fsync")) {
530-
if (!BSON_ITER_HOLDS_BOOL (&inner)) {
531-
goto fail;
532-
}
533-
BEGIN_IGNORE_DEPRECATIONS
534-
mongoc_write_concern_set_fsync (write_concern, bson_iter_bool (&inner));
535-
END_IGNORE_DEPRECATIONS
497+
// fsync removed in C driver 2.0.
498+
goto fail;
536499
} else if (BSON_ITER_IS_KEY (&inner, "j")) {
537500
if (!BSON_ITER_HOLDS_BOOL (&inner)) {
538501
goto fail;

src/libmongoc/src/mongoc/mongoc-write-concern.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ mongoc_write_concern_copy (const mongoc_write_concern_t *write_concern) BSON_GNU
4444
MONGOC_EXPORT (void)
4545
mongoc_write_concern_destroy (mongoc_write_concern_t *write_concern);
4646

47-
BSON_DEPRECATED ("The fsync parameter is deprecated")
48-
MONGOC_EXPORT (bool) mongoc_write_concern_get_fsync (const mongoc_write_concern_t *write_concern);
49-
50-
BSON_DEPRECATED ("The fsync parameter is deprecated")
51-
MONGOC_EXPORT (void) mongoc_write_concern_set_fsync (mongoc_write_concern_t *write_concern, bool fsync_);
52-
5347
MONGOC_EXPORT (bool)
5448
mongoc_write_concern_get_journal (const mongoc_write_concern_t *write_concern);
5549

src/libmongoc/tests/test-mongoc-cursor.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ _test_common_clone_w_concerns (void *ctx)
136136
mongoc_read_concern_set_level (read_concern, MONGOC_READ_CONCERN_LEVEL_LOCAL);
137137
write_concern = mongoc_write_concern_new ();
138138
ASSERT (write_concern);
139-
mongoc_write_concern_set_fsync (write_concern, true);
140139
mongoc_write_concern_set_journal (write_concern, true);
141140
mongoc_write_concern_set_wmajority (write_concern, 1000);
142141
cursor->write_concern = write_concern;
@@ -157,7 +156,7 @@ _test_common_clone_w_concerns (void *ctx)
157156
ASSERT_MATCH (_mongoc_read_concern_get_bson (cloned->read_concern), "{'level': 'local'}");
158157
bson = _mongoc_write_concern_get_bson (cloned->write_concern);
159158
ASSERT (bson);
160-
ASSERT (bson_iter_init_find (&iter, bson, "fsync") && BSON_ITER_HOLDS_BOOL (&iter) && bson_iter_bool (&iter));
159+
ASSERT (!bson_iter_init_find (&iter, bson, "fsync")); // Deprecated "fsync" removed in C driver 2.0.
161160
ASSERT (bson_iter_init_find (&iter, bson, "j") && BSON_ITER_HOLDS_BOOL (&iter) && bson_iter_bool (&iter));
162161
ASSERT (bson_iter_init_find (&iter, bson, "w") && BSON_ITER_HOLDS_UTF8 (&iter));
163162
ASSERT_CMPSTR (bson_iter_utf8 (&iter, NULL), "majority");

0 commit comments

Comments
 (0)