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

Opening a named partition starts transactions before being able to specify the default timeout and retry limit #61

Open
KrzysFR opened this issue Mar 10, 2015 · 1 comment
Labels
api Issues or changes related to the client API

Comments

@KrzysFR
Copy link
Member

KrzysFR commented Mar 10, 2015

Currently, the way to specify default timeout and retry limit settings is to set them on a IFdbDatabase instance, and they will be automatically used by all transactions created from this database instance.

When using the Fdb.OpenNamedPartitionAsync(...) method to create a database instance, you have to wait for the method to complete to get back the db instance and configure it. The problem is that this method need to start a few transactions to read the root subspace prefix from the Directory Layer, which means that it will use the defaults timeout settings (infinite). If the database is not started (or unavailable), then OpenNamedPartitionAsync(..) will not return until either the db goes online, or the CancellationToken passed to it fires (or never if it was CancellationToken.None).

We need a way to pass the various settings to the OpenAsync(...) and OpenNamedPartitionAsync(...) so that they can use them.

Something like

var settings = new FdbConnectionSettings
{
    ClusterFile = @".....",
    DbName = "DB",
    DefaultTimeout = 60 * 1000,
    DefaultRetryLimit = 10,
    // ... more settings to come in future versions?
}
var db = await Fdb.OpenNamedPartitionAsync(settings, someGlobalCancellationToken);
// db.DefaultTimeout => 60000
// db.DefaultRetryLimit => 10
@KrzysFR KrzysFR added the api Issues or changes related to the client API label Mar 10, 2015
KrzysFR added a commit that referenced this issue May 11, 2018
…sync

- Add FdbConnectionOptions class that contains all main options and knobs for the client (clusterfile, timeouts, etc...)
- Fdb.OpenAsync(FdbConnectionOptions) can open any database, including named partitions
- Fdb.Directory.OpenNamedPartitionAsync are deprecated since OpenAsync can do the job
- Allows settings default timeout and retry limits before accessing the Directory Layer (cf Issue #61)
@KrzysFR
Copy link
Member Author

KrzysFR commented May 11, 2018

I changed the code to be able to specify default timeout/retry limits, AND open a named partition in a single call to Fdb.OpenAsync(...).

Sample code that opens the named partition ("Foo", "Bar") with a default timeout of 30 sec.

var options = new FdbConnectionOptions()
{
    ClusterFiler = "....", // null for default path
    DefaultTimeout = TimeSpan.FromSeconds(30), // 0 for infinite timeout (default)
    PartitionPath = new [] { "Foo", "Bar" }, // or no partition if null
    // other settings
}
var db = await Fdb.OpenAsync(options, ct);
// opens the database, and switch to the named partitions automatically
// will abort after 30sec if db is not available

This means that Fdb.Directory.OpenNamedPartitions(...) is now obsolete (Fdb.OpenAsync(FdbConnectionOptions, ...) can do the same job).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues or changes related to the client API
Projects
None yet
Development

No branches or pull requests

1 participant